-
Notifications
You must be signed in to change notification settings - Fork 249
/
Copy pathevents_discord_import.go
127 lines (101 loc) · 4.49 KB
/
events_discord_import.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package signal
import (
"github.com/status-im/status-go/protocol/discord"
)
const (
// EventDiscordCategoriesAndChannelsExtracted triggered when categories and
// channels for exported discord files have been successfully extracted
EventDiscordCategoriesAndChannelsExtracted = "community.discordCategoriesAndChannelsExtracted"
// EventDiscordCommunityImportProgress is triggered during the import
// of a discord community as it progresses
EventDiscordCommunityImportProgress = "community.discordCommunityImportProgress"
// EventDiscordCommunityImportFinished triggered when importing
// the discord community into status was successful
EventDiscordCommunityImportFinished = "community.discordCommunityImportFinished"
// EventDiscordCommunityImportCancelled triggered when importing
// the discord community was cancelled
EventDiscordCommunityImportCancelled = "community.discordCommunityImportCancelled"
// EventDiscordCommunityImportCleanedUp triggered when the community has been cleaned up (deleted)
EventDiscordCommunityImportCleanedUp = "community.discordCommunityImportCleanedUp"
// EventDiscordChannelImportProgress is triggered during the import
// of a discord community channel as it progresses
EventDiscordChannelImportProgress = "community.discordChannelImportProgress"
// EventDiscordChannelImportFinished triggered when importing
// the discord community channel into status was successful
EventDiscordChannelImportFinished = "community.discordChannelImportFinished"
// EventDiscordChannelImportCancelled triggered when importing
// the discord community channel was cancelled
EventDiscordChannelImportCancelled = "community.discordChannelImportCancelled"
)
type DiscordCategoriesAndChannelsExtractedSignal struct {
Categories []*discord.Category `json:"discordCategories"`
Channels []*discord.Channel `json:"discordChannels"`
OldestMessageTimestamp int64 `json:"oldestMessageTimestamp"`
Errors map[string]*discord.ImportError `json:"errors"`
}
type DiscordCommunityImportProgressSignal struct {
ImportProgress *discord.ImportProgress `json:"importProgress"`
}
type DiscordCommunityImportFinishedSignal struct {
CommunityID string `json:"communityId"`
}
type DiscordCommunityImportCancelledSignal struct {
CommunityID string `json:"communityId"`
}
type DiscordCommunityImportCleanedUpSignal struct {
CommunityID string `json:"communityId"`
}
type DiscordChannelImportProgressSignal struct {
ImportProgress *discord.ImportProgress `json:"importProgress"`
}
type DiscordChannelImportFinishedSignal struct {
CommunityID string `json:"communityId"`
ChannelID string `json:"channelId"`
}
type DiscordChannelImportCancelledSignal struct {
ChannelID string `json:"channelId"`
}
func SendDiscordCategoriesAndChannelsExtracted(categories []*discord.Category, channels []*discord.Channel, oldestMessageTimestamp int64, errors map[string]*discord.ImportError) {
send(EventDiscordCategoriesAndChannelsExtracted, DiscordCategoriesAndChannelsExtractedSignal{
Categories: categories,
Channels: channels,
OldestMessageTimestamp: oldestMessageTimestamp,
Errors: errors,
})
}
func SendDiscordCommunityImportProgress(importProgress *discord.ImportProgress) {
send(EventDiscordCommunityImportProgress, DiscordCommunityImportProgressSignal{
ImportProgress: importProgress,
})
}
func SendDiscordChannelImportProgress(importProgress *discord.ImportProgress) {
send(EventDiscordChannelImportProgress, DiscordChannelImportProgressSignal{
ImportProgress: importProgress,
})
}
func SendDiscordCommunityImportFinished(communityID string) {
send(EventDiscordCommunityImportFinished, DiscordCommunityImportFinishedSignal{
CommunityID: communityID,
})
}
func SendDiscordChannelImportFinished(communityID string, channelID string) {
send(EventDiscordChannelImportFinished, DiscordChannelImportFinishedSignal{
CommunityID: communityID,
ChannelID: channelID,
})
}
func SendDiscordCommunityImportCancelled(communityID string) {
send(EventDiscordCommunityImportCancelled, DiscordCommunityImportCancelledSignal{
CommunityID: communityID,
})
}
func SendDiscordCommunityImportCleanedUp(communityID string) {
send(EventDiscordCommunityImportCleanedUp, DiscordCommunityImportCleanedUpSignal{
CommunityID: communityID,
})
}
func SendDiscordChannelImportCancelled(channelID string) {
send(EventDiscordChannelImportCancelled, DiscordChannelImportCancelledSignal{
ChannelID: channelID,
})
}