Skip to content

Commit

Permalink
fix callsign with phone
Browse files Browse the repository at this point in the history
  • Loading branch information
kdudkov committed Sep 28, 2023
1 parent 8d7cc6a commit 8c44777
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
4 changes: 4 additions & 0 deletions cmd/goatak_server/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ func (app *App) ProcessItem(msg *cot.CotMessage) {
c.Update(msg)
} else {
app.Logger.Infof("new %s %s (%s) %s", cl, msg.GetUid(), msg.GetCallsign(), msg.GetType())
if msg.GetCallsign() == "" {
app.Logger.Infof("%s", msg.TakMessage.GetCotEvent().GetDetail().GetXmlDetail())
_ = logToFile(msg)
}
app.items.Store(model.FromMsg(msg))
}
}
Expand Down
23 changes: 16 additions & 7 deletions pkg/cot/cotmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,40 @@ func (m *CotMessage) GetCallsign() string {
return ""
}

return m.TakMessage.GetCotEvent().GetDetail().GetContact().GetCallsign()
if s := m.TakMessage.GetCotEvent().GetDetail().GetContact().GetCallsign(); s != "" {
return s
}

// if phonenumber is in contact - contact is in xmldetails
return m.Detail.GetFirst("contact").GetAttr("callsign")
}

func (m *CotMessage) GetTeam() string {
func (m *CotMessage) GetEndpoint() string {
if m == nil || m.TakMessage == nil {
return ""
}

return m.TakMessage.GetCotEvent().GetDetail().GetGroup().GetName()
if s := m.TakMessage.GetCotEvent().GetDetail().GetContact().GetEndpoint(); s != "" {
return s
}

return m.Detail.GetFirst("contact").GetAttr("endpoint")
}

func (m *CotMessage) GetRole() string {
func (m *CotMessage) GetTeam() string {
if m == nil || m.TakMessage == nil {
return ""
}

return m.TakMessage.GetCotEvent().GetDetail().GetGroup().GetRole()
return m.TakMessage.GetCotEvent().GetDetail().GetGroup().GetName()
}

func (m *CotMessage) GetEndpoint() string {
func (m *CotMessage) GetRole() string {
if m == nil || m.TakMessage == nil {
return ""
}

return m.TakMessage.GetCotEvent().GetDetail().GetContact().GetEndpoint()
return m.TakMessage.GetCotEvent().GetDetail().GetGroup().GetRole()
}

func (m *CotMessage) GetStale() time.Time {
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (i *Item) Update(msg *cot.CotMessage) {

i.class = GetClass(msg)
i.cottype = msg.TakMessage.GetCotEvent().GetType()
i.callsign = msg.TakMessage.GetCotEvent().GetDetail().GetContact().GetCallsign()
i.callsign = msg.GetCallsign()
i.staleTime = cot.TimeFromMillis(msg.TakMessage.GetCotEvent().GetStaleTime())
i.startTime = cot.TimeFromMillis(msg.TakMessage.GetCotEvent().GetStartTime())
i.sendTime = cot.TimeFromMillis(msg.TakMessage.GetCotEvent().GetSendTime())
Expand Down

0 comments on commit 8c44777

Please sign in to comment.