Create portals for recent chats automatically
This commit is contained in:
parent
7e90ec8c14
commit
e94ea17dad
2 changed files with 20 additions and 11 deletions
|
@ -16,7 +16,7 @@
|
|||
* [ ] Typing notifications
|
||||
* [ ] Read receipts
|
||||
* Misc
|
||||
* [ ] Automatic portal creation
|
||||
* [ ] After login
|
||||
* [x] Automatic portal creation
|
||||
* [x] After login
|
||||
* [x] When receiving message
|
||||
* [ ] Private chat creation by inviting Matrix ghost of remote user to new room
|
||||
|
|
29
user.go
29
user.go
|
@ -541,6 +541,25 @@ func (user *User) HandleEvent(event interface{}) {
|
|||
user.zlog.Err(err).Msg("Failed to update session in database")
|
||||
}
|
||||
case *binary.Conversation:
|
||||
user.syncConversation(v)
|
||||
case *binary.Message:
|
||||
portal := user.GetPortalByID(v.GetConversationID())
|
||||
portal.messages <- PortalMessage{evt: v, source: user}
|
||||
case *events.ClientReady:
|
||||
user.zlog.Trace().Any("data", v).Msg("Client is ready!")
|
||||
go func() {
|
||||
for _, conv := range v.Conversations {
|
||||
user.syncConversation(conv)
|
||||
}
|
||||
}()
|
||||
case *events.BrowserActive:
|
||||
user.zlog.Trace().Any("data", v).Msg("Browser active")
|
||||
default:
|
||||
user.zlog.Trace().Any("data", v).Msg("Unknown event")
|
||||
}
|
||||
}
|
||||
|
||||
func (user *User) syncConversation(v *binary.Conversation) {
|
||||
portal := user.GetPortalByID(v.GetConversationID())
|
||||
if portal.MXID != "" {
|
||||
portal.UpdateMetadata(user, v)
|
||||
|
@ -550,16 +569,6 @@ func (user *User) HandleEvent(event interface{}) {
|
|||
user.zlog.Err(err).Msg("Error creating Matrix room from conversation event")
|
||||
}
|
||||
}
|
||||
case *binary.Message:
|
||||
portal := user.GetPortalByID(v.GetConversationID())
|
||||
portal.messages <- PortalMessage{evt: v, source: user}
|
||||
case *events.ClientReady:
|
||||
user.zlog.Trace().Any("data", v).Msg("Client is ready!")
|
||||
case *events.BrowserActive:
|
||||
user.zlog.Trace().Any("data", v).Msg("Browser active")
|
||||
default:
|
||||
user.zlog.Trace().Any("data", v).Msg("Unknown event")
|
||||
}
|
||||
}
|
||||
|
||||
func (user *User) updateChatMute(portal *Portal, mutedUntil time.Time) {
|
||||
|
|
Loading…
Reference in a new issue