This commit is contained in:
2023-09-06 22:17:06 -05:00
parent 3db8e1da05
commit d6f94287d4
17 changed files with 62 additions and 46 deletions

34
user.go
View File

@@ -359,7 +359,7 @@ func (user *User) Connect() bool {
func (user *User) RestoreSession() bool {
if len(user.Token) > 0 {
err := user.Conn.SubscribeToUser(context.TODO(), groupme.ID(user.GMID), user.Token)
err := user.Conn.SubscribeToUser(context.TODO(), user.GMID, user.Token)
if err != nil {
fmt.Println(err)
}
@@ -616,7 +616,7 @@ func (user *User) syncPortals(createAll bool) {
})
}
for _, dm := range user.ChatList {
portal := user.bridge.GetPortalByGMID(database.NewPortalKey(dm.OtherUser.ID, user.GMID))
portal := user.bridge.GetPortalByGMID(database.NewPortalKey(dm.LastMessage.ConversationID, user.GMID))
chats = append(chats, Chat{
Portal: portal,
LastMessageTime: uint64(dm.UpdatedAt.ToTime().Unix()),
@@ -624,25 +624,25 @@ func (user *User) syncPortals(createAll bool) {
})
}
for _, chat := range chats {
//var inSpace, ok bool
//if inSpace, ok = existingKeys[chat.Portal.Key]; !ok || !inCommunity {
// inCommunity = user.addPortalToCommunity(chat.Portal)
// if chat.Portal.IsPrivateChat() {
// puppet := user.bridge.GetPuppetByGMID(chat.Portal.Key.GMID)
// user.ad.addPuppetToCommunity(puppet)
// }
//}
portalKeys = append(portalKeys, chat.Portal.Key)
}
user.log.Infoln("Read chat list, updating user-portal mapping")
//for _, chat := range chats {
//var inSpace, ok bool
//if inSpace, ok = existingKeys[chat.Portal.Key]; !ok || !inCommunity {
// inCommunity = user.addPortalToCommunity(chat.Portal)
// if chat.Portal.IsPrivateChat() {
// puppet := user.bridge.GetPuppetByGMID(chat.Portal.Key.GMID)
// user.ad.addPuppetToCommunity(puppet)
// }
//}
//portalKeys = append(portalKeys, chat.Portal.Key)
//}
//user.log.Infoln("Read chat list, updating user-portal mapping")
err := user.SetPortalKeys(portalKeys) //user.SetPortalKeys(portalKeys)
err := user.SetPortalKeys(portalKeys)
if err != nil {
user.log.Warnln("Failed to update user-portal mapping:", err)
}
sort.Sort(chats)
limit := user.bridge.Config.Bridge.HistorySync.MaxInitialConversations
limit := 5 //user.bridge.Config.Bridge.HistorySync.MaxInitialConversations
if limit < 0 {
limit = len(chats)
}
@@ -774,7 +774,7 @@ func (user *User) handleMessageLoop() {
puppet := user.bridge.GetPuppetByGMID(msg.data.UserID)
portal := user.bridge.GetPortalByGMID(msg.chat)
if puppet != nil {
puppet.Sync(user, &groupme.Member{
puppet.Sync(nil, &groupme.Member{
UserID: msg.data.UserID,
Nickname: msg.data.Name,
ImageURL: msg.data.AvatarURL,