Skip to content

Commit

Permalink
more wip
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <sumner@beeper.com>
  • Loading branch information
sumnerevans committed Jul 19, 2023
1 parent 1b631d7 commit e7d6caf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
15 changes: 2 additions & 13 deletions backfillqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,14 @@ func (user *User) HandleBackfillRequestsLoop(backfillTypes []database.BackfillTy
req := user.BackfillQueue.GetNextBackfill(user.MXID, backfillTypes, waitForBackfillTypes, reCheckChannel)
user.log.Infofln("Handling backfill request %s", req)

conv := user.bridge.DB.HistorySync.GetConversation(user.MXID, *req.Portal)
conv := user.bridge.DB.HistorySync.GetConversation(user.MXID, req.PortalGUID)
if conv == nil {
user.log.Debugfln("Could not find history sync conversation data for %s", req.Portal.String())
user.log.Debugfln("Could not find history sync conversation data for %s", req.PortalGUID)
req.MarkDone()
continue
}
portal := user.GetPortalByJID(conv.PortalKey.JID)

// Update the client store with basic chat settings.
if conv.MuteEndTime.After(time.Now()) {
user.Client.Store.ChatSettings.PutMutedUntil(conv.PortalKey.JID, conv.MuteEndTime)
}
if conv.Archived {
user.Client.Store.ChatSettings.PutArchived(conv.PortalKey.JID, true)
}
if conv.Pinned > 0 {
user.Client.Store.ChatSettings.PutPinned(conv.PortalKey.JID, true)
}

if conv.EphemeralExpiration != nil && portal.ExpirationTime != *conv.EphemeralExpiration {
portal.ExpirationTime = *conv.EphemeralExpiration
portal.Update(nil)
Expand Down
2 changes: 1 addition & 1 deletion config/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type BridgeConfig struct {
}

func (bc BridgeConfig) GetResendBridgeInfo() bool {
return false
return true
}

func (bc BridgeConfig) GetManagementRoomTexts() bridgeconfig.ManagementRoomTexts {
Expand Down
15 changes: 9 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,12 @@ func (br *IMBridge) Start() {
br.ZLog.Fatal().Err(err).Msg("Error getting chats from database")
}

chatInfos := make([]ChatInfo, len(chats))
chatInfos := make([]*imessage.ChatInfo, len(chats))
for i, chat := range chats {
chatInfos[i] = ChatInfo{
GUID: chat.ChatGUID,
ThreadID: chat.ThreadID,
chatInfos[i], err = br.IM.GetChatInfo(chat.ChatGUID, chat.ThreadID)
if err != nil {
// TODO do something intelligent here
br.ZLog.Fatal().Err(err).Msg("Error getting chat info from database")
}
}

Expand All @@ -504,11 +505,13 @@ func (br *IMBridge) Start() {
// Create all of the portals locally
portals := []*Portal{}
txn, err := br.DB.Begin()
for guid, roomID := range resp {
for guid, roomInfo := range resp {
portal := br.GetPortalByGUID(guid)
portal.MXID = roomID
portal.MXID = roomInfo.RoomID
portal.Update(txn)
portals = append(portals, portal)
// Add backfill for this user
// use roomInfo.EarliestBridgedTimestamp
}
if err = txn.Commit(); err != nil {
// TODO do something intelligent here
Expand Down
2 changes: 1 addition & 1 deletion user.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type User struct {

spaceMembershipChecked bool

BackfillQueue *BackfillQueue
BackfillQueue *BackfillQueue
}

var _ bridge.User = (*User)(nil)
Expand Down

0 comments on commit e7d6caf

Please sign in to comment.