[pairing] Fetch history on receiving pubchat installation.

This commit is contained in:
Roman Volosovskyi 2021-09-23 15:56:38 +03:00
parent cef8ec2508
commit 5793470fad
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
4 changed files with 14 additions and 23 deletions

View File

@ -1 +1 @@
0.88.2
0.88.3

View File

@ -2741,20 +2741,12 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
// We join and re-register as we want to receive mentions from the newly joined public chat
if addedChat != nil {
_, err = m.Join(addedChat)
_, err = m.createPublicChat(addedChat.ID, messageState.Response)
if err != nil {
allMessagesProcessed = false
logger.Error("error joining chat", zap.Error(err))
continue
}
logger.Debug("newly synced public chat, re-registering for push notifications")
err := m.reregisterForPushNotifications()
if err != nil {
allMessagesProcessed = false
logger.Warn("could not re-register for push notifications", zap.Error(err))
continue
}
}
case protobuf.SyncCommunity:

View File

@ -102,13 +102,7 @@ func (m *Messenger) initChatSyncFields(chat *Chat) error {
return nil
}
func (m *Messenger) CreatePublicChat(request *requests.CreatePublicChat) (*MessengerResponse, error) {
if err := request.Validate(); err != nil {
return nil, err
}
chatID := request.ID
func (m *Messenger) createPublicChat(chatID string, response *MessengerResponse) (*MessengerResponse, error) {
chat, ok := m.allChats.Load(chatID)
if !ok {
chat = CreatePublicChat(chatID, m.getTimesource())
@ -155,12 +149,22 @@ func (m *Messenger) CreatePublicChat(request *requests.CreatePublicChat) (*Messe
return nil, err
}
response := &MessengerResponse{}
response.AddChat(chat)
return response, nil
}
func (m *Messenger) CreatePublicChat(request *requests.CreatePublicChat) (*MessengerResponse, error) {
if err := request.Validate(); err != nil {
return nil, err
}
chatID := request.ID
response := &MessengerResponse{}
return m.createPublicChat(chatID, response)
}
func (m *Messenger) CreateProfileChat(request *requests.CreateProfileChat) (*MessengerResponse, error) {
if err := request.Validate(); err != nil {
return nil, err

View File

@ -365,11 +365,6 @@ func (m *Messenger) HandleSyncInstallationPublicChat(state *ReceivedMessageState
}
chat := CreatePublicChat(chatID, state.Timesource)
timestamp := uint32(state.Timesource.GetCurrentTime() / 1000)
chat.SyncedTo = timestamp
chat.SyncedFrom = timestamp
state.AllChats.Store(chat.ID, chat)
state.Response.AddChat(chat)