forked from MirrorHub/mautrix-whatsapp
Ignore old call start events
This commit is contained in:
parent
64f5610f39
commit
146efa9e94
1 changed files with 6 additions and 4 deletions
10
user.go
10
user.go
|
@ -452,8 +452,10 @@ func (user *User) handleHistorySync(evt *waProto.HistorySync) {
|
||||||
user.log.Infofln("Finished handling history sync with type %s, chunk order %d, progress %d%%", evt.GetSyncType(), evt.GetChunkOrder(), evt.GetProgress())
|
user.log.Infofln("Finished handling history sync with type %s, chunk order %d, progress %d%%", evt.GetSyncType(), evt.GetChunkOrder(), evt.GetProgress())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) handleCallStart(sender types.JID, id, callType string) {
|
const callEventMaxAge = 15 * time.Minute
|
||||||
if !user.bridge.Config.Bridge.CallStartNotices {
|
|
||||||
|
func (user *User) handleCallStart(sender types.JID, id, callType string, ts time.Time) {
|
||||||
|
if !user.bridge.Config.Bridge.CallStartNotices || ts.Add(callEventMaxAge).Before(time.Now()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
portal := user.GetPortalByJID(sender)
|
portal := user.GetPortalByJID(sender)
|
||||||
|
@ -531,9 +533,9 @@ func (user *User) HandleEvent(event interface{}) {
|
||||||
portal := user.GetPortalByJID(v.Info.Chat)
|
portal := user.GetPortalByJID(v.Info.Chat)
|
||||||
portal.messages <- PortalMessage{evt: v, source: user}
|
portal.messages <- PortalMessage{evt: v, source: user}
|
||||||
case *events.CallOffer:
|
case *events.CallOffer:
|
||||||
user.handleCallStart(v.CallCreator, v.CallID, "")
|
user.handleCallStart(v.CallCreator, v.CallID, "", v.Timestamp)
|
||||||
case *events.CallOfferNotice:
|
case *events.CallOfferNotice:
|
||||||
user.handleCallStart(v.CallCreator, v.CallID, v.Type)
|
user.handleCallStart(v.CallCreator, v.CallID, v.Type, v.Timestamp)
|
||||||
case *events.CallTerminate, *events.CallRelayLatency, *events.CallAccept, *events.UnknownCallEvent:
|
case *events.CallTerminate, *events.CallRelayLatency, *events.CallAccept, *events.UnknownCallEvent:
|
||||||
// ignore
|
// ignore
|
||||||
case *events.UndecryptableMessage:
|
case *events.UndecryptableMessage:
|
||||||
|
|
Loading…
Reference in a new issue