diff --git a/protocol/communities/manager.go b/protocol/communities/manager.go index 78899627f..7396a6f35 100644 --- a/protocol/communities/manager.go +++ b/protocol/communities/manager.go @@ -108,14 +108,15 @@ func (md archiveMDSlice) Less(i, j int) bool { } type Subscription struct { - Community *Community - Invitations []*protobuf.CommunityInvitation - CreatingHistoryArchivesSignal *signal.CreatingHistoryArchivesSignal - HistoryArchivesCreatedSignal *signal.HistoryArchivesCreatedSignal - NoHistoryArchivesCreatedSignal *signal.NoHistoryArchivesCreatedSignal - HistoryArchivesSeedingSignal *signal.HistoryArchivesSeedingSignal - HistoryArchivesUnseededSignal *signal.HistoryArchivesUnseededSignal - HistoryArchiveDownloadedSignal *signal.HistoryArchiveDownloadedSignal + Community *Community + Invitations []*protobuf.CommunityInvitation + CreatingHistoryArchivesSignal *signal.CreatingHistoryArchivesSignal + HistoryArchivesCreatedSignal *signal.HistoryArchivesCreatedSignal + NoHistoryArchivesCreatedSignal *signal.NoHistoryArchivesCreatedSignal + HistoryArchivesSeedingSignal *signal.HistoryArchivesSeedingSignal + HistoryArchivesUnseededSignal *signal.HistoryArchivesUnseededSignal + HistoryArchiveDownloadedSignal *signal.HistoryArchiveDownloadedSignal + DownloadingHistoryArchivesFinishedSignal *signal.DownloadingHistoryArchivesFinishedSignal } type CommunityResponse struct { diff --git a/protocol/messenger_config.go b/protocol/messenger_config.go index eeea297b6..ce1ee0fb7 100644 --- a/protocol/messenger_config.go +++ b/protocol/messenger_config.go @@ -45,6 +45,7 @@ type MessengerSignalsHandler interface { HistoryArchivesSeeding(communityID string) HistoryArchivesUnseeded(communityID string) HistoryArchiveDownloaded(communityID string, from int, to int) + DownloadingHistoryArchivesFinished(communityID string) StatusUpdatesTimedOut(statusUpdates *[]UserStatus) DiscordCategoriesAndChannelsExtracted(categories []*discord.Category, channels []*discord.Channel, oldestMessageTimestamp int64, errors map[string]*discord.ImportError) } diff --git a/protocol/messenger_handler.go b/protocol/messenger_handler.go index 96ae12657..f8c5ad27e 100644 --- a/protocol/messenger_handler.go +++ b/protocol/messenger_handler.go @@ -949,6 +949,7 @@ func (m *Messenger) HandleHistoryArchiveMagnetlinkMessage(state *ReceivedMessage signal.SendNewMessages(response) localnotifications.PushMessages(notifications) } + m.config.messengerSignalsHandler.DownloadingHistoryArchivesFinished(types.EncodeHex(id)) }() return m.communitiesManager.UpdateMagnetlinkMessageClock(id, clock) diff --git a/services/ext/signal.go b/services/ext/signal.go index c19a5a5a7..8d82dc453 100644 --- a/services/ext/signal.go +++ b/services/ext/signal.go @@ -120,6 +120,10 @@ func (m *MessengerSignalsHandler) HistoryArchiveDownloaded(communityID string, f signal.SendHistoryArchiveDownloaded(communityID, from, to) } +func (m *MessengerSignalsHandler) DownloadingHistoryArchivesFinished(communityID string) { + signal.SendDownloadingHistoryArchivesFinished(communityID) +} + func (m *MessengerSignalsHandler) StatusUpdatesTimedOut(statusUpdates *[]protocol.UserStatus) { signal.SendStatusUpdatesTimedOut(statusUpdates) } diff --git a/signal/events_community_archives.go b/signal/events_community_archives.go index 9cb97d21e..e05eaf450 100644 --- a/signal/events_community_archives.go +++ b/signal/events_community_archives.go @@ -27,6 +27,9 @@ const ( // EventHistoryArchiveDownloaded is triggered when the community member node // has downloaded an individual community archive EventHistoryArchiveDownloaded = "community.historyArchiveDownloaded" + // EventDownloadingHistoryArchivesFinished is triggered when the community member node + // has downloaded all archives + EventDownloadingHistoryArchivesFinished = "community.downloadingHistoryArchivesFinished" ) type CreatingHistoryArchivesSignal struct { @@ -59,6 +62,10 @@ type HistoryArchiveDownloadedSignal struct { To int `json:"to"` } +type DownloadingHistoryArchivesFinishedSignal struct { + CommunityID string `json:"communityId"` +} + func SendHistoryArchivesProtocolEnabled() { send(EventHistoryArchivesProtocolEnabled, nil) } @@ -102,3 +109,9 @@ func SendHistoryArchiveDownloaded(communityID string, from int, to int) { To: to, }) } + +func SendDownloadingHistoryArchivesFinished(communityID string) { + send(EventDownloadingHistoryArchivesFinished, DownloadingHistoryArchivesFinishedSignal{ + CommunityID: communityID, + }) +}