[pairing] Fetch history on receiving pubchat installation.
This commit is contained in:
parent
cef8ec2508
commit
5793470fad
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue