Add more logs for syncing conversations
This commit is contained in:
parent
7618afed7f
commit
13a8d9b9a9
3 changed files with 7 additions and 13 deletions
10
portal.go
10
portal.go
|
@ -842,16 +842,6 @@ func (portal *Portal) ensureUserInvited(user *User) bool {
|
||||||
return user.ensureInvited(portal.MainIntent(), portal.MXID, portal.IsPrivateChat())
|
return user.ensureInvited(portal.MainIntent(), portal.MXID, portal.IsPrivateChat())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (portal *Portal) UpdateMatrixRoom(user *User, groupInfo *gmproto.Conversation) bool {
|
|
||||||
if len(portal.MXID) == 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
portal.ensureUserInvited(user)
|
|
||||||
portal.UpdateMetadata(user, groupInfo)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (portal *Portal) GetBasePowerLevels() *event.PowerLevelsEventContent {
|
func (portal *Portal) GetBasePowerLevels() *event.PowerLevelsEventContent {
|
||||||
anyone := 0
|
anyone := 0
|
||||||
nope := 99
|
nope := 99
|
||||||
|
|
|
@ -238,6 +238,9 @@ func (prov *ProvisioningAPI) StartChat(w http.ResponseWriter, r *http.Request) {
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
convCopy := proto.Clone(resp.Conversation).(*gmproto.Conversation)
|
||||||
|
convCopy.LatestMessage = nil
|
||||||
|
prov.zlog.Debug().Any("conversation_data", convCopy).Msg("Got conversation data for start chat")
|
||||||
portal := user.GetPortalByID(resp.Conversation.ConversationID)
|
portal := user.GetPortalByID(resp.Conversation.ConversationID)
|
||||||
err = portal.CreateMatrixRoom(user, resp.Conversation)
|
err = portal.CreateMatrixRoom(user, resp.Conversation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
7
user.go
7
user.go
|
@ -650,7 +650,7 @@ func (user *User) HandleEvent(event interface{}) {
|
||||||
user.zlog.Err(err).Msg("Failed to update session in database")
|
user.zlog.Err(err).Msg("Failed to update session in database")
|
||||||
}
|
}
|
||||||
case *gmproto.Conversation:
|
case *gmproto.Conversation:
|
||||||
user.syncConversation(v)
|
user.syncConversation(v, "event")
|
||||||
case *gmproto.Message:
|
case *gmproto.Message:
|
||||||
portal := user.GetPortalByID(v.GetConversationID())
|
portal := user.GetPortalByID(v.GetConversationID())
|
||||||
portal.messages <- PortalMessage{evt: v, source: user}
|
portal.messages <- PortalMessage{evt: v, source: user}
|
||||||
|
@ -692,7 +692,7 @@ func (user *User) fetchAndSyncConversations() {
|
||||||
}
|
}
|
||||||
user.zlog.Info().Int("count", len(resp.GetConversations())).Msg("Syncing conversations")
|
user.zlog.Info().Int("count", len(resp.GetConversations())).Msg("Syncing conversations")
|
||||||
for _, conv := range resp.GetConversations() {
|
for _, conv := range resp.GetConversations() {
|
||||||
user.syncConversation(conv)
|
user.syncConversation(conv, "sync")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,7 +793,7 @@ func (user *User) Logout(state status.BridgeState, unpair bool) (logoutOK bool)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) syncConversation(v *gmproto.Conversation) {
|
func (user *User) syncConversation(v *gmproto.Conversation, source string) {
|
||||||
updateType := v.GetStatus()
|
updateType := v.GetStatus()
|
||||||
portal := user.GetPortalByID(v.GetConversationID())
|
portal := user.GetPortalByID(v.GetConversationID())
|
||||||
convCopy := proto.Clone(v).(*gmproto.Conversation)
|
convCopy := proto.Clone(v).(*gmproto.Conversation)
|
||||||
|
@ -801,6 +801,7 @@ func (user *User) syncConversation(v *gmproto.Conversation) {
|
||||||
log := portal.zlog.With().
|
log := portal.zlog.With().
|
||||||
Str("action", "sync conversation").
|
Str("action", "sync conversation").
|
||||||
Str("conversation_status", updateType.String()).
|
Str("conversation_status", updateType.String()).
|
||||||
|
Str("data_source", source).
|
||||||
Str("room_id", portal.MXID.String()).
|
Str("room_id", portal.MXID.String()).
|
||||||
Interface("conversation_data", convCopy).
|
Interface("conversation_data", convCopy).
|
||||||
Logger()
|
Logger()
|
||||||
|
|
Loading…
Reference in a new issue