github.com/status-im/status-go@v1.1.0/signal/events_discord_import.go (about)

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