feat: add signal indicating that history messages are being imported
In order to give clients more insights about archive messages being processed, we're adding this additional signal that informs clients when the import of downloaded history archive messages has started.
This commit is contained in:
parent
684e9654de
commit
22b5690cda
|
@ -137,6 +137,7 @@ type Subscription struct {
|
||||||
HistoryArchiveDownloadedSignal *signal.HistoryArchiveDownloadedSignal
|
HistoryArchiveDownloadedSignal *signal.HistoryArchiveDownloadedSignal
|
||||||
DownloadingHistoryArchivesStartedSignal *signal.DownloadingHistoryArchivesStartedSignal
|
DownloadingHistoryArchivesStartedSignal *signal.DownloadingHistoryArchivesStartedSignal
|
||||||
DownloadingHistoryArchivesFinishedSignal *signal.DownloadingHistoryArchivesFinishedSignal
|
DownloadingHistoryArchivesFinishedSignal *signal.DownloadingHistoryArchivesFinishedSignal
|
||||||
|
ImportingHistoryArchiveMessagesSignal *signal.ImportingHistoryArchiveMessagesSignal
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommunityResponse struct {
|
type CommunityResponse struct {
|
||||||
|
|
|
@ -146,6 +146,10 @@ func (m *Messenger) handleCommunitiesHistoryArchivesSubscription(c chan *communi
|
||||||
if sub.DownloadingHistoryArchivesStartedSignal != nil {
|
if sub.DownloadingHistoryArchivesStartedSignal != nil {
|
||||||
m.config.messengerSignalsHandler.DownloadingHistoryArchivesStarted(sub.DownloadingHistoryArchivesStartedSignal.CommunityID)
|
m.config.messengerSignalsHandler.DownloadingHistoryArchivesStarted(sub.DownloadingHistoryArchivesStartedSignal.CommunityID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sub.ImportingHistoryArchiveMessagesSignal != nil {
|
||||||
|
m.config.messengerSignalsHandler.ImportingHistoryArchiveMessages(sub.ImportingHistoryArchiveMessagesSignal.CommunityID)
|
||||||
|
}
|
||||||
case <-m.quit:
|
case <-m.quit:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ type MessengerSignalsHandler interface {
|
||||||
HistoryArchiveDownloaded(communityID string, from int, to int)
|
HistoryArchiveDownloaded(communityID string, from int, to int)
|
||||||
DownloadingHistoryArchivesStarted(communityID string)
|
DownloadingHistoryArchivesStarted(communityID string)
|
||||||
DownloadingHistoryArchivesFinished(communityID string)
|
DownloadingHistoryArchivesFinished(communityID string)
|
||||||
|
ImportingHistoryArchiveMessages(communityID string)
|
||||||
StatusUpdatesTimedOut(statusUpdates *[]UserStatus)
|
StatusUpdatesTimedOut(statusUpdates *[]UserStatus)
|
||||||
DiscordCategoriesAndChannelsExtracted(categories []*discord.Category, channels []*discord.Channel, oldestMessageTimestamp int64, errors map[string]*discord.ImportError)
|
DiscordCategoriesAndChannelsExtracted(categories []*discord.Category, channels []*discord.Channel, oldestMessageTimestamp int64, errors map[string]*discord.ImportError)
|
||||||
DiscordCommunityImportProgress(importProgress *discord.ImportProgress)
|
DiscordCommunityImportProgress(importProgress *discord.ImportProgress)
|
||||||
|
|
|
@ -963,6 +963,8 @@ func (m *Messenger) HandleHistoryArchiveMagnetlinkMessage(state *ReceivedMessage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.config.messengerSignalsHandler.ImportingHistoryArchiveMessages(types.EncodeHex(id))
|
||||||
|
|
||||||
err = m.handleImportedMessages(importedMessages)
|
err = m.handleImportedMessages(importedMessages)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("failed to handle imported messages", err)
|
log.Println("failed to handle imported messages", err)
|
||||||
|
|
|
@ -116,6 +116,10 @@ func (m *MessengerSignalsHandler) DownloadingHistoryArchivesStarted(communityID
|
||||||
signal.SendDownloadingHistoryArchivesStarted(communityID)
|
signal.SendDownloadingHistoryArchivesStarted(communityID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MessengerSignalsHandler) ImportingHistoryArchiveMessages(communityID string) {
|
||||||
|
signal.SendImportingHistoryArchiveMessages(communityID)
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MessengerSignalsHandler) DownloadingHistoryArchivesFinished(communityID string) {
|
func (m *MessengerSignalsHandler) DownloadingHistoryArchivesFinished(communityID string) {
|
||||||
signal.SendDownloadingHistoryArchivesFinished(communityID)
|
signal.SendDownloadingHistoryArchivesFinished(communityID)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,9 @@ const (
|
||||||
// EventHistoryArchiveDownloaded is triggered when the community member node
|
// EventHistoryArchiveDownloaded is triggered when the community member node
|
||||||
// has downloaded an individual community archive
|
// has downloaded an individual community archive
|
||||||
EventHistoryArchiveDownloaded = "community.historyArchiveDownloaded"
|
EventHistoryArchiveDownloaded = "community.historyArchiveDownloaded"
|
||||||
|
// EventImportingHistoryArchiveMessages is triggered when the community member node
|
||||||
|
// has starts importing downloaded archive messages into the database
|
||||||
|
EventImportingHistoryArchiveMessages = "community.importingHistoryArchiveMessages"
|
||||||
// EventDownloadingHistoryArchivesFinished is triggered when the community member node
|
// EventDownloadingHistoryArchivesFinished is triggered when the community member node
|
||||||
// has downloaded all archives
|
// has downloaded all archives
|
||||||
EventDownloadingHistoryArchivesFinished = "community.downloadingHistoryArchivesFinished"
|
EventDownloadingHistoryArchivesFinished = "community.downloadingHistoryArchivesFinished"
|
||||||
|
@ -69,6 +72,10 @@ type DownloadingHistoryArchivesStartedSignal struct {
|
||||||
CommunityID string `json:"communityId"`
|
CommunityID string `json:"communityId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ImportingHistoryArchiveMessagesSignal struct {
|
||||||
|
CommunityID string `json:"communityId"`
|
||||||
|
}
|
||||||
|
|
||||||
type DownloadingHistoryArchivesFinishedSignal struct {
|
type DownloadingHistoryArchivesFinishedSignal struct {
|
||||||
CommunityID string `json:"communityId"`
|
CommunityID string `json:"communityId"`
|
||||||
}
|
}
|
||||||
|
@ -123,6 +130,12 @@ func SendDownloadingHistoryArchivesStarted(communityID string) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SendImportingHistoryArchiveMessages(communityID string) {
|
||||||
|
send(EventImportingHistoryArchiveMessages, ImportingHistoryArchiveMessagesSignal{
|
||||||
|
CommunityID: communityID,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func SendDownloadingHistoryArchivesFinished(communityID string) {
|
func SendDownloadingHistoryArchivesFinished(communityID string) {
|
||||||
send(EventDownloadingHistoryArchivesFinished, DownloadingHistoryArchivesFinishedSignal{
|
send(EventDownloadingHistoryArchivesFinished, DownloadingHistoryArchivesFinishedSignal{
|
||||||
CommunityID: communityID,
|
CommunityID: communityID,
|
||||||
|
|
Loading…
Reference in New Issue