add mapping for radio call signs

This commit is contained in:
Jonas Leder 2025-01-11 13:04:45 +01:00
commit e13a00c42a
3 changed files with 19 additions and 2 deletions

View file

@ -40,6 +40,6 @@ func Init() {
if os.Getenv("DB_MIGRATE") != "false" {
log.Log.Info("Executing database migrations")
Db.AutoMigrate(&tables.StatusMessage{})
Db.AutoMigrate(&tables.StatusMessage{}, &tables.RadioCallSign{})
}
}

View file

@ -0,0 +1,7 @@
package tables
type RadioCallSign struct {
ID uint `gorm:"primaryKey"`
RadioName string
RadioCallSign string
}

View file

@ -79,8 +79,18 @@ func getFmsListe(messageParts []string) string {
response := ""
log.Log.Debug("Received ", len(statusMessages), " entries")
for _, status := range statusMessages {
var radioCallSign tables.RadioCallSign
err = database.Db.Where("radio_name = ?", status.Name).First(&radioCallSign).Error
if err != nil {
log.Log.Error("Failed retreiving radio call sign: ", err.Error())
return "Internal error"
}
if radioCallSign.RadioName == "" {
log.Log.Info("No radio definition for ", status.Name, " skipping")
continue
}
response += fmt.Sprintf("SetFMSListe\t%s\tBF/FF\tSTATE\tCITY\t%s\tFZ->LST\t%s\t\t%d\tman\t%s\t0,0\n",
status.Date.Format("02.01.06 / 15:04:05"), status.Name, getFmsName(status.Status), status.Status, status.FmsId)
status.Date.Format("02.01.06 / 15:04:05"), status.Name, getFmsName(status.Status), status.Status, radioCallSign.RadioCallSign)
}
return response
}