undo some changes I made
This commit is contained in:
parent
a2f0042536
commit
da6b214abb
30
portal.go
30
portal.go
@ -190,25 +190,6 @@ type Portal struct {
|
|||||||
|
|
||||||
const MaxMessageAgeToCreatePortal = 5 * 60 // 5 minutes
|
const MaxMessageAgeToCreatePortal = 5 * 60 // 5 minutes
|
||||||
|
|
||||||
func (portal *Portal) syncDoublePuppetDetailsAfterCreate(source *User) {
|
|
||||||
doublePuppet := portal.bridge.GetPuppetByCustomMXID(source.MXID)
|
|
||||||
if doublePuppet == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
source.Conn.Store.ChatsLock.RLock()
|
|
||||||
chat, ok := source.Conn.Store.Chats[portal.Key.JID]
|
|
||||||
source.Conn.Store.ChatsLock.RUnlock()
|
|
||||||
if !ok {
|
|
||||||
portal.log.Debugln("Not syncing chat mute/tags with %s: chat info not found", source.MXID)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
source.syncChatDoublePuppetDetails(doublePuppet, Chat{
|
|
||||||
Chat: chat,
|
|
||||||
Portal: portal,
|
|
||||||
}, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func (portal *Portal) handleMessageLoop() {
|
func (portal *Portal) handleMessageLoop() {
|
||||||
for msg := range portal.messages {
|
for msg := range portal.messages {
|
||||||
if len(portal.MXID) == 0 {
|
if len(portal.MXID) == 0 {
|
||||||
@ -222,15 +203,14 @@ func (portal *Portal) handleMessageLoop() {
|
|||||||
portal.log.Errorln("Failed to create portal room:", err)
|
portal.log.Errorln("Failed to create portal room:", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
portal.syncDoublePuppetDetailsAfterCreate(msg.source)
|
|
||||||
}
|
}
|
||||||
portal.backfillLock.Lock()
|
portal.backfillLock.Lock()
|
||||||
portal.handleMessage(msg, false)
|
portal.handleMessage(msg)
|
||||||
portal.backfillLock.Unlock()
|
portal.backfillLock.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (portal *Portal) handleMessage(msg PortalMessage, isBackfill bool) {
|
func (portal *Portal) handleMessage(msg PortalMessage) {
|
||||||
if len(portal.MXID) == 0 {
|
if len(portal.MXID) == 0 {
|
||||||
portal.log.Warnln("handleMessage called even though portal.MXID is empty")
|
portal.log.Warnln("handleMessage called even though portal.MXID is empty")
|
||||||
return
|
return
|
||||||
@ -985,11 +965,11 @@ func (portal *Portal) CreateMatrixRoom(user *User) error {
|
|||||||
portal.log.Debugln("else: it's not a private chat")
|
portal.log.Debugln("else: it's not a private chat")
|
||||||
var err error
|
var err error
|
||||||
metadata, err = user.Client.ShowGroup(context.TODO(), groupme.ID(portal.Key.JID))
|
metadata, err = user.Client.ShowGroup(context.TODO(), groupme.ID(portal.Key.JID))
|
||||||
if err == nil && metadata.Status == 0 {
|
if err == nil {
|
||||||
portal.Name = metadata.Name
|
portal.Name = metadata.Name
|
||||||
portal.Topic = metadata.Topic
|
// portal.Topic = metadata.Topic
|
||||||
}
|
}
|
||||||
portal.UpdateAvatar(user, nil, false)
|
portal.UpdateAvatar(user, metadata.ImageURL, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
bridgeInfoStateKey, bridgeInfo := portal.getBridgeInfo()
|
bridgeInfoStateKey, bridgeInfo := portal.getBridgeInfo()
|
||||||
|
23
user.go
23
user.go
@ -677,29 +677,6 @@ func (user *User) getDirectChats() map[id.UserID][]id.RoomID {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) syncChatDoublePuppetDetails(doublePuppet *Puppet, chat Chat, justCreated bool) {
|
|
||||||
if doublePuppet == nil || doublePuppet.CustomIntent() == nil || len(chat.Portal.MXID) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
intent := doublePuppet.CustomIntent()
|
|
||||||
if chat.UnreadCount == 0 && (justCreated || !user.bridge.Config.Bridge.MarkReadOnlyOnCreate) {
|
|
||||||
lastMessage := user.bridge.DB.Message.GetLastInChatBefore(chat.Portal.Key, chat.ReceivedAt.Unix())
|
|
||||||
if lastMessage != nil {
|
|
||||||
err := intent.MarkReadWithContent(chat.Portal.MXID, lastMessage.MXID, &CustomReadReceipt{DoublePuppet: true})
|
|
||||||
if err != nil {
|
|
||||||
user.log.Warnfln("Failed to mark %s in %s as read after backfill: %v", lastMessage.MXID, chat.Portal.MXID, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if chat.UnreadCount == -1 {
|
|
||||||
user.log.Debugfln("Invalid unread count (missing field?) in chat info %+v", chat.Source)
|
|
||||||
}
|
|
||||||
if justCreated || !user.bridge.Config.Bridge.TagOnlyOnCreate {
|
|
||||||
user.updateChatMute(intent, chat.Portal, chat.MutedUntil)
|
|
||||||
user.updateChatTag(intent, chat.Portal, user.bridge.Config.Bridge.ArchiveTag, chat.IsArchived)
|
|
||||||
user.updateChatTag(intent, chat.Portal, user.bridge.Config.Bridge.PinnedTag, chat.IsPinned)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (user *User) UpdateDirectChats(chats map[id.UserID][]id.RoomID) {
|
func (user *User) UpdateDirectChats(chats map[id.UserID][]id.RoomID) {
|
||||||
if !user.bridge.Config.Bridge.SyncDirectChatList {
|
if !user.bridge.Config.Bridge.SyncDirectChatList {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user