feat: add signal for starting history archive downloads
This commit is contained in:
parent
6e96586bdb
commit
194f26f3b4
|
@ -135,6 +135,7 @@ type Subscription struct {
|
|||
HistoryArchivesSeedingSignal *signal.HistoryArchivesSeedingSignal
|
||||
HistoryArchivesUnseededSignal *signal.HistoryArchivesUnseededSignal
|
||||
HistoryArchiveDownloadedSignal *signal.HistoryArchiveDownloadedSignal
|
||||
DownloadingHistoryArchivesStartedSignal *signal.DownloadingHistoryArchivesStartedSignal
|
||||
DownloadingHistoryArchivesFinishedSignal *signal.DownloadingHistoryArchivesFinishedSignal
|
||||
}
|
||||
|
||||
|
@ -2107,6 +2108,12 @@ func (m *Manager) DownloadHistoryArchivesByMagnetlink(communityID types.HexBytes
|
|||
|
||||
sort.Sort(sort.Reverse(archiveHashes))
|
||||
|
||||
m.publish(&Subscription{
|
||||
DownloadingHistoryArchivesStartedSignal: &signal.DownloadingHistoryArchivesStartedSignal{
|
||||
CommunityID: communityID.String(),
|
||||
},
|
||||
})
|
||||
|
||||
for _, hd := range archiveHashes {
|
||||
hash := hd.hash
|
||||
metadata := index.Archives[hash]
|
||||
|
|
|
@ -140,7 +140,11 @@ func (m *Messenger) handleCommunitiesHistoryArchivesSubscription(c chan *communi
|
|||
}
|
||||
|
||||
if sub.DownloadingHistoryArchivesFinishedSignal != nil {
|
||||
m.config.messengerSignalsHandler.DownloadingHistoryArchivesFinished(sub.HistoryArchiveDownloadedSignal.CommunityID)
|
||||
m.config.messengerSignalsHandler.DownloadingHistoryArchivesFinished(sub.DownloadingHistoryArchivesFinishedSignal.CommunityID)
|
||||
}
|
||||
|
||||
if sub.DownloadingHistoryArchivesStartedSignal != nil {
|
||||
m.config.messengerSignalsHandler.DownloadingHistoryArchivesStarted(sub.DownloadingHistoryArchivesStartedSignal.CommunityID)
|
||||
}
|
||||
case <-m.quit:
|
||||
return
|
||||
|
|
|
@ -44,6 +44,7 @@ type MessengerSignalsHandler interface {
|
|||
HistoryArchivesSeeding(communityID string)
|
||||
HistoryArchivesUnseeded(communityID string)
|
||||
HistoryArchiveDownloaded(communityID string, from int, to int)
|
||||
DownloadingHistoryArchivesStarted(communityID string)
|
||||
DownloadingHistoryArchivesFinished(communityID string)
|
||||
StatusUpdatesTimedOut(statusUpdates *[]UserStatus)
|
||||
DiscordCategoriesAndChannelsExtracted(categories []*discord.Category, channels []*discord.Channel, oldestMessageTimestamp int64, errors map[string]*discord.ImportError)
|
||||
|
|
|
@ -112,6 +112,10 @@ func (m *MessengerSignalsHandler) HistoryArchiveDownloaded(communityID string, f
|
|||
signal.SendHistoryArchiveDownloaded(communityID, from, to)
|
||||
}
|
||||
|
||||
func (m *MessengerSignalsHandler) DownloadingHistoryArchivesStarted(communityID string) {
|
||||
signal.SendDownloadingHistoryArchivesStarted(communityID)
|
||||
}
|
||||
|
||||
func (m *MessengerSignalsHandler) DownloadingHistoryArchivesFinished(communityID string) {
|
||||
signal.SendDownloadingHistoryArchivesFinished(communityID)
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ const (
|
|||
// EventHistoryArchivesUnseeded is triggered when the community owner node
|
||||
// drops a torrent for a particular community
|
||||
EventHistoryArchivesUnseeded = "community.historyArchivesUnseeded"
|
||||
// EventDownloadingHistoryArchivesFinished is triggered when the community member node
|
||||
// has downloaded all archives
|
||||
EventDownloadingHistoryArchivesStarted = "community.downloadingHistoryArchivesStarted"
|
||||
// EventHistoryArchiveDownloaded is triggered when the community member node
|
||||
// has downloaded an individual community archive
|
||||
EventHistoryArchiveDownloaded = "community.historyArchiveDownloaded"
|
||||
|
@ -62,6 +65,10 @@ type HistoryArchiveDownloadedSignal struct {
|
|||
To int `json:"to"`
|
||||
}
|
||||
|
||||
type DownloadingHistoryArchivesStartedSignal struct {
|
||||
CommunityID string `json:"communityId"`
|
||||
}
|
||||
|
||||
type DownloadingHistoryArchivesFinishedSignal struct {
|
||||
CommunityID string `json:"communityId"`
|
||||
}
|
||||
|
@ -110,6 +117,12 @@ func SendHistoryArchiveDownloaded(communityID string, from int, to int) {
|
|||
})
|
||||
}
|
||||
|
||||
func SendDownloadingHistoryArchivesStarted(communityID string) {
|
||||
send(EventDownloadingHistoryArchivesStarted, DownloadingHistoryArchivesStartedSignal{
|
||||
CommunityID: communityID,
|
||||
})
|
||||
}
|
||||
|
||||
func SendDownloadingHistoryArchivesFinished(communityID string) {
|
||||
send(EventDownloadingHistoryArchivesFinished, DownloadingHistoryArchivesFinishedSignal{
|
||||
CommunityID: communityID,
|
||||
|
|
Loading…
Reference in New Issue