mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-13 17:13:11 +01:00
Fix crash and add more logging
This commit is contained in:
parent
a40584db41
commit
83f4cf2811
2 changed files with 7 additions and 1 deletions
|
@ -358,7 +358,7 @@ func (handler *CommandHandler) CommandDeleteAllPortals(ce *CommandEvent) {
|
|||
}
|
||||
}
|
||||
customPuppet := handler.bridge.GetPuppetByCustomMXID(ce.User.MXID)
|
||||
if customPuppet != nil {
|
||||
if customPuppet != nil && customPuppet.CustomIntent() != nil {
|
||||
intent := customPuppet.CustomIntent()
|
||||
leave = func(portal *Portal) {
|
||||
if len(portal.MXID) > 0 {
|
||||
|
|
6
user.go
6
user.go
|
@ -308,6 +308,7 @@ func (user *User) intPostLogin() {
|
|||
}
|
||||
|
||||
func (user *User) syncPortals(createAll bool) {
|
||||
user.log.Infoln("Reading chat list")
|
||||
chats := make(ChatList, 0, len(user.Conn.Store.Chats))
|
||||
portalKeys := make([]database.PortalKey, 0, len(user.Conn.Store.Chats))
|
||||
for _, chat := range user.Conn.Store.Chats {
|
||||
|
@ -325,6 +326,7 @@ func (user *User) syncPortals(createAll bool) {
|
|||
})
|
||||
portalKeys = append(portalKeys, portal.Key)
|
||||
}
|
||||
user.log.Infoln("Read chat list, updating user-portal mapping")
|
||||
err := user.SetPortalKeys(portalKeys)
|
||||
if err != nil {
|
||||
user.log.Warnln("Failed to update user-portal mapping:", err)
|
||||
|
@ -335,6 +337,7 @@ func (user *User) syncPortals(createAll bool) {
|
|||
limit = len(chats)
|
||||
}
|
||||
now := uint64(time.Now().Unix())
|
||||
user.log.Infoln("Syncing portals")
|
||||
for i, chat := range chats {
|
||||
if chat.LastMessageTime+user.bridge.Config.Bridge.SyncChatMaxAge < now {
|
||||
break
|
||||
|
@ -348,15 +351,18 @@ func (user *User) syncPortals(createAll bool) {
|
|||
}
|
||||
}
|
||||
}
|
||||
user.log.Infoln("Finished syncing portals")
|
||||
}
|
||||
|
||||
func (user *User) syncPuppets() {
|
||||
user.log.Infoln("Syncing puppet info from contacts")
|
||||
for jid, contact := range user.Conn.Store.Contacts {
|
||||
if strings.HasSuffix(jid, whatsappExt.NewUserSuffix) {
|
||||
puppet := user.bridge.GetPuppetByJID(contact.Jid)
|
||||
puppet.Sync(user, contact)
|
||||
}
|
||||
}
|
||||
user.log.Infoln("Finished syncing puppet info from contacts")
|
||||
}
|
||||
|
||||
func (user *User) updateLastConnectionIfNecessary() {
|
||||
|
|
Loading…
Reference in a new issue