Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
fix sync message
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Sep 2, 2022
1 parent a560d15 commit 16b8d0f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 deletions.
3 changes: 1 addition & 2 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package textsecure

import (
"github.com/golang/protobuf/proto"
"github.com/signal-golang/textsecure/config"
"github.com/signal-golang/textsecure/groupsv2"
signalservice "github.com/signal-golang/textsecure/protobuf"
log "github.com/sirupsen/logrus"
Expand All @@ -20,7 +19,7 @@ func handleMessage(srcE164 string, srcUUID string, timestamp uint64, b []byte) e

if dm := content.GetDataMessage(); dm != nil {
return handleDataMessage(srcE164, srcUUID, timestamp, dm)
} else if sm := content.GetSyncMessage(); sm != nil && config.ConfigFile.Tel == srcE164 {
} else if sm := content.GetSyncMessage(); sm != nil {
return handleSyncMessage(srcE164, srcUUID, timestamp, sm)
} else if cm := content.GetCallMessage(); cm != nil {
return handleCallMessage(srcE164, srcUUID, timestamp, cm)
Expand Down
66 changes: 37 additions & 29 deletions sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,55 +17,63 @@ import (
// handleSyncMessage handles an incoming SyncMessage.
func handleSyncMessage(src string, srcUUID string, timestamp uint64, sm *signalservice.SyncMessage) error {
log.Debugf("[textsecure] SyncMessage recieved at %d", timestamp)

if sm.GetContacts() != nil {
if sm.GetSent() != nil {
log.Debugln("[textsecure] SyncMessage getSent")
return handleSyncSent(sm.GetSent(), timestamp)
} else if sm.GetContacts() != nil {
log.Debugln("[textsecure] SyncMessage unhandled contacts")
return nil
} else if sm.GetGroups() != nil {
log.Debugln("[textsecure] SyncMessage groups")
return nil
} else if sm.GetRequest() != nil {
log.Debugln("[textsecure] SyncMessage getRequest")
return handleSyncRequest(sm.GetRequest())
} else if sm.GetRead() != nil {
log.Debugln("[textsecure] SyncMessage getRead")
return handleSyncRead(sm.GetRead())
} else if sm.GetViewed() != nil {
log.Debugln("[textsecure] SyncMessage unhandled getViewed")
return nil
} else if sm.GetViewOnceOpen() != nil {
log.Debugln("[textsecure] SyncMessage unhandled GetViewOnceOpen")
return nil
} else if sm.GetViewOnceOpen() != nil {
log.Debugln("[textsecure] SyncMessage unhandled GetBlockedList")
return nil
} else if sm.GetBlocked() != nil {
log.Debugln("[textsecure] SyncMessage blocked")
return nil
} else if sm.GetConfiguration() != nil {
log.Debugln("[textsecure] SyncMessage unahndled configuration")
log.Debugln("[textsecure] SyncMessage unhandled getBlocked")
return nil
} else if sm.GetSent() != nil {
log.Debugln("[textsecure] SyncMessage getSent")
return handleSyncSent(sm.GetSent(), timestamp)
} else if sm.GetStickerPackOperation() != nil {
log.Debugln("[textsecure] SyncMessage unhandled GetStickerPackOperation")
return nil
} else if sm.GetRequest() != nil {
log.Debugln("[textsecure] SyncMessage getRequest")
return handleSyncRequest(sm.GetRequest())

} else if sm.GetVerified() != nil {
log.Debugln("[textsecure] SyncMessage verified")
unidentifiedAccess, err := unidentifiedAccess.GetAccessForSync(config.ConfigFile.ProfileKey, config.ConfigFile.Certificate)
if err != nil {
return err
}
return sendVerifiedMessage(sm.GetVerified(), unidentifiedAccess)

} else if sm.GetConfiguration() != nil {
log.Debugln("[textsecure] SyncMessage unahndled configuration")
return nil
} else if sm.GetPadding() != nil {
log.Debugln("[textsecure] SyncMessage padding")
log.Debugln("[textsecure] SyncMessage unhandled padding")
return nil
} else if sm.GetStickerPackOperation() != nil {
log.Debugln("[textsecure] SyncMessage unhandled GetStickerPackOperation")
return nil
} else if sm.GetViewOnceOpen() != nil {
log.Debugln("[textsecure] SyncMessage unhandled GetViewOnceOpen")
return nil

} else if sm.GetFetchLatest() != nil {
log.Debugln("[textsecure] SyncMessage GetFetchLatest")
log.Debugln("[textsecure] SyncMessage unhandled GetFetchLatest")
return nil
} else if sm.GetKeys() != nil {
log.Debugln("[textsecure] SyncMessage unhandled GetKeys")
return nil
} else if sm.GetMessageRequestResponse() != nil {
log.Debugln("[textsecure] SyncMessage unhandled GetMessageRequestResponse")
return nil
} else if sm.GetOutgoingPayment() != nil {
log.Debugln("[textsecure] SyncMessage unhandled GetOutgoing payment")
return nil
} else if sm.GetViewed() != nil {
log.Debugln("[textsecure] SyncMessage unhandled getViewed")
return nil
} else if sm.GetPniIdentity() != nil {
log.Debug("[textsecure] SyncMessage unhandled getPniIdentity")
return nil
} else if sm.GetPniChangeNumber() != nil {
log.Debugln("[textsecure] SyncMessage unhandled getPniChangeNumber")
return nil
} else {
log.Errorf("[textsecure] SyncMessage contains no known sync types")
Expand Down

0 comments on commit 16b8d0f

Please sign in to comment.