Documentation ¶
Index ¶
- func AddChannel(ctx context.Context, db *gorm.DB, client *slack.Client, p *AddChannelParams) error
- func AddMember(ctx context.Context, db *gorm.DB, client *slack.Client, p *AddMemberParams) error
- func CheckPair(ctx context.Context, db *gorm.DB, client *slack.Client, p *CheckPairParams) error
- func CreateMatches(ctx context.Context, db *gorm.DB, client *slack.Client, p *CreateMatchesParams) error
- func CreatePair(ctx context.Context, db *gorm.DB, client *slack.Client, p *CreatePairParams) error
- func CreateRound(ctx context.Context, db *gorm.DB, client *slack.Client, p *CreateRoundParams) error
- func DeleteChannel(ctx context.Context, db *gorm.DB, client *slack.Client, p *DeleteChannelParams) error
- func DeleteMember(ctx context.Context, db *gorm.DB, client *slack.Client, p *DeleteMemberParams) error
- func EndRound(ctx context.Context, db *gorm.DB, client *slack.Client, p *EndRoundParams) error
- func ExecJob[T any](ctx context.Context, db *gorm.DB, client *slack.Client, job *models.Job, ...) error
- func FirstChatRouletteRound(t time.Time, weekday string, hour int) time.Time
- func GetBotUserID(ctx context.Context, client *slack.Client) (string, error)
- func GreetMember(ctx context.Context, db *gorm.DB, client *slack.Client, p *GreetMemberParams) error
- func HandleAppHomeEvent(ctx context.Context, client *slack.Client, db *gorm.DB, p *AppHomeParams) error
- func HandleCheckPairButtons(ctx context.Context, client *http.Client, db *gorm.DB, ...) error
- func HandleGreetMemberButton(ctx context.Context, client *slack.Client, ...) error
- func IsUserABot(ctx context.Context, client *slack.Client, userID string) (bool, error)
- func NextChatRouletteRound(t time.Time, interval models.IntervalEnum) time.Time
- func NotifyPair(ctx context.Context, db *gorm.DB, client *slack.Client, p *NotifyPairParams) error
- func PairParticipants(pairings []ChatRoulettePair) map[string]string
- func QueueAddChannelJob(ctx context.Context, db *gorm.DB, p *AddChannelParams) error
- func QueueAddMemberJob(ctx context.Context, db *gorm.DB, p *AddMemberParams) error
- func QueueCheckPairJob(ctx context.Context, db *gorm.DB, p *CheckPairParams) error
- func QueueCreateMatchesJob(ctx context.Context, db *gorm.DB, p *CreateMatchesParams) error
- func QueueCreatePairJob(ctx context.Context, db *gorm.DB, p *CreatePairParams) error
- func QueueCreateRoundJob(ctx context.Context, db *gorm.DB, p *CreateRoundParams) error
- func QueueDeleteChannelJob(ctx context.Context, db *gorm.DB, p *DeleteChannelParams) error
- func QueueDeleteMemberJob(ctx context.Context, db *gorm.DB, p *DeleteMemberParams) error
- func QueueEndRoundJob(ctx context.Context, db *gorm.DB, p *EndRoundParams) error
- func QueueGreetMemberJob(ctx context.Context, db *gorm.DB, p *GreetMemberParams) error
- func QueueJob[T any](ctx context.Context, db *gorm.DB, gJob models.GenericJob[T]) error
- func QueueNotifyPairJob(ctx context.Context, db *gorm.DB, p *NotifyPairParams) error
- func QueueReportStatsJob(ctx context.Context, db *gorm.DB, p *ReportStatsParams) error
- func QueueSyncChannelsJob(ctx context.Context, db *gorm.DB, p *SyncChannelsParams) error
- func QueueSyncMembersJob(ctx context.Context, db *gorm.DB, p *SyncMembersParams) error
- func QueueUpdateChannelJob(ctx context.Context, db *gorm.DB, p *UpdateChannelParams) error
- func QueueUpdateMatchJob(ctx context.Context, db *gorm.DB, p *UpdateMatchParams) error
- func QueueUpdateMemberJob(ctx context.Context, db *gorm.DB, p *UpdateMemberParams) error
- func RenderOnboardingCalendlyView(ctx context.Context, interaction *slack.InteractionCallback, baseURL string) ([]byte, error)
- func RenderOnboardingLocationView(ctx context.Context, interaction *slack.InteractionCallback, baseURL string) ([]byte, error)
- func RenderOnboardingProfileView(ctx context.Context, interaction *slack.InteractionCallback, baseURL string) ([]byte, error)
- func RenderOnboardingTimezoneView(ctx context.Context, interaction *slack.InteractionCallback, baseURL string) ([]byte, error)
- func ReportStats(ctx context.Context, db *gorm.DB, client *slack.Client, p *ReportStatsParams) error
- func RespondGreetMemberWebhook(ctx context.Context, client *http.Client, ...) error
- func SyncChannels(ctx context.Context, db *gorm.DB, client *slack.Client, p *SyncChannelsParams) error
- func SyncMembers(ctx context.Context, db *gorm.DB, client *slack.Client, p *SyncMembersParams) error
- func UpdateChannel(ctx context.Context, db *gorm.DB, client *slack.Client, p *UpdateChannelParams) error
- func UpdateMatch(ctx context.Context, db *gorm.DB, client *slack.Client, p *UpdateMatchParams) error
- func UpdateMember(ctx context.Context, db *gorm.DB, client *slack.Client, p *UpdateMemberParams) error
- func UpsertMemberCalendlyLink(ctx context.Context, db *gorm.DB, interaction *slack.InteractionCallback) error
- func UpsertMemberLocationInfo(ctx context.Context, db *gorm.DB, interaction *slack.InteractionCallback) error
- func UpsertMemberProfileInfo(ctx context.Context, db *gorm.DB, interaction *slack.InteractionCallback) error
- func UpsertMemberTimezoneInfo(ctx context.Context, db *gorm.DB, interaction *slack.InteractionCallback) error
- func ValidateMemberCalendlyLink(ctx context.Context, link string) error
- func ValidateMemberProfileInfo(ctx context.Context, interaction *slack.InteractionCallback) error
- type AddChannelParams
- type AddMemberParams
- type AppHomeParams
- type ChatRoulettePair
- type CheckPairParams
- type CreateMatchesParams
- type CreatePairParams
- type CreateRoundParams
- type DeleteChannelParams
- type DeleteMemberParams
- type EndRoundParams
- type GreetMemberParams
- type JobFunc
- type NotifyPairParams
- type ReportStatsParams
- type SyncChannelsParams
- type SyncMembersParams
- type UpdateChannelParams
- type UpdateMatchParams
- type UpdateMemberParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddChannel ¶
AddChannel adds a Slack channel to the database.
func AddMember ¶
AddMember adds a new member of a Slack channel to the database and begins the onboarding process for them.
func CheckPair ¶
CheckPair sends a private group message to a chat-roulette pair to check if they have had a chance to meet during this round of chat-roulette.
func CreateMatches ¶
func CreateMatches(ctx context.Context, db *gorm.DB, client *slack.Client, p *CreateMatchesParams) error
CreateMatches creates matches between active participants for a round of chat-roulette.
func CreatePair ¶
CreatePair creates a pairing between 2 matched participants.
func CreateRound ¶
func CreateRound(ctx context.Context, db *gorm.DB, client *slack.Client, p *CreateRoundParams) error
CreateRound adds a new chat roulette round for a Slack channel to the database.
func DeleteChannel ¶
func DeleteChannel(ctx context.Context, db *gorm.DB, client *slack.Client, p *DeleteChannelParams) error
DeleteChannel deletes a Slack channel from the database.
func DeleteMember ¶
func DeleteMember(ctx context.Context, db *gorm.DB, client *slack.Client, p *DeleteMemberParams) error
DeleteMember deletes a member who has left a Slack channel from the database.
func ExecJob ¶
func ExecJob[T any](ctx context.Context, db *gorm.DB, client *slack.Client, job *models.Job, f JobFunc[T]) error
ExecJob is a generic function for executing job functions.
func FirstChatRouletteRound ¶
FirstChatRouletteRound returns the timestamp of the first chat roulette round.
func GetBotUserID ¶
GetBotUserID uses Slack's auth.test API method to retrieve the UserID of the chat-roulette bot
func GreetMember ¶
func GreetMember(ctx context.Context, db *gorm.DB, client *slack.Client, p *GreetMemberParams) error
GreetMember greets a new member of a Slack channel with a welcome message.
func HandleAppHomeEvent ¶
func HandleAppHomeEvent(ctx context.Context, client *slack.Client, db *gorm.DB, p *AppHomeParams) error
HandleAppHomeEvent handles the app_home_opened event and publishes the view for the App Home.
func HandleCheckPairButtons ¶
func HandleCheckPairButtons(ctx context.Context, client *http.Client, db *gorm.DB, interaction *slack.InteractionCallback) error
HandleCheckPairButtons processes the webhook sent by Slack when a user clicks on the button in the message sent by the CHECK_PAIR job confirming if they have had a chance to meet the participant that they were paired with in this round of chat roulette. A response is sent overwriting the button in the original message, so that it cannot be clicked multiple times. This interaction contains multiple buttons, so we do need to parse the action. An UPDATE_MATCH job is then queued to modify the "has_met" column for the match in the database.
func HandleGreetMemberButton ¶
func HandleGreetMemberButton(ctx context.Context, client *slack.Client, interaction *slack.InteractionCallback) error
HandleGreetMemberButton processes the webhook sent by Slack when a user clicks on the button in the GREET_MESSAGE job confirming that they wish to participate in chat roulette. A modal is opened to collect onboarding information and upon submission, a response is sent to Slack overwriting the button in the original message, so that it cannot be clicked multiple times. Since this interaction only contains a single button, we do not need to parse the action.
func IsUserABot ¶
IsUserABot uses Slack's users.info API method to check if the given user is actually a bot.
func NextChatRouletteRound ¶
NextChatRouletteRound returns the timestamp of the next chat roulette round.
func NotifyPair ¶
NotifyPair notifies a pair of chat-roulette participants that they have been matched for this round of chat-roulette.
func PairParticipants ¶
func PairParticipants(pairings []ChatRoulettePair) map[string]string
PairParticipants takes a list of potential matches for a round of chat roulette and returns the pairings of participants.
func QueueAddChannelJob ¶
QueueAddChannelJob adds a new ADD_CHANNEL job to the queue
func QueueAddMemberJob ¶
QueueAddChannelJob adds a new ADD_MEMBER job to the queue.
func QueueCheckPairJob ¶
QueueCheckPairJob adds a new CHECK_PAIR job to the queue.
func QueueCreateMatchesJob ¶
QueueCreateMatchesJob adds a new CREATE_MATCHES job to the queue.
func QueueCreatePairJob ¶
QueueCreatePairJob adds a new CREATE_PAIR job to the queue.
func QueueCreateRoundJob ¶
QueueCreateRoundJob adds a new CREATE_ROUND job to the queue.
func QueueDeleteChannelJob ¶
DeleteChannelJob adds a new DELETE_CHANNEL job to the queue.
func QueueDeleteMemberJob ¶
QueueDeleteMemberJob adds a new DELETE_MEMBER job to the queue.
func QueueEndRoundJob ¶
QueueEndRoundJob adds a new END_ROUND job to the queue.
func QueueGreetMemberJob ¶
QueueGreetMemberJob adds a new GREET_MEMBER job to the queue.
func QueueJob ¶
QueueJob is a generic function for adding a background job to the database job queue.
func QueueNotifyPairJob ¶
QueueNotifyPairJob adds a new NOTIFY_PAIR job to the queue.
func QueueReportStatsJob ¶
QueueReportStatsJob adds a new REPORT_STATS job to the queue.
func QueueSyncChannelsJob ¶
QueueSyncChannelsJob adds a new SYNC_CHANNELS job to the queue.
func QueueSyncMembersJob ¶
QueueSyncMembersJob adds a new SYNC_MEMBERS job to the queue.
func QueueUpdateChannelJob ¶
UpdateChannelJob adds a new UPDATE_CHANNEL job to the queue.
func QueueUpdateMatchJob ¶
QueueUpdateMatchJob adds a new UPDATE_MATCH job to the queue.
func QueueUpdateMemberJob ¶
QueueUpdateMemberJob adds a new UPDATE_MEMBER job to the queue.
func RenderOnboardingCalendlyView ¶
func RenderOnboardingCalendlyView(ctx context.Context, interaction *slack.InteractionCallback, baseURL string) ([]byte, error)
RenderOnboardingCalendlyView renders the view template for collecting a new member's calendly link.
func RenderOnboardingLocationView ¶
func RenderOnboardingLocationView(ctx context.Context, interaction *slack.InteractionCallback, baseURL string) ([]byte, error)
RenderOnboardingLocationView renders the view template for collecting a new member's location data.
func RenderOnboardingProfileView ¶
func RenderOnboardingProfileView(ctx context.Context, interaction *slack.InteractionCallback, baseURL string) ([]byte, error)
RenderOnboardingProfileView renders the view template for collecting a new member's profile info.
func RenderOnboardingTimezoneView ¶
func RenderOnboardingTimezoneView(ctx context.Context, interaction *slack.InteractionCallback, baseURL string) ([]byte, error)
RenderOnboardingTimezoneView renders the view template for collecting a new member's timezone data.
func ReportStats ¶
func ReportStats(ctx context.Context, db *gorm.DB, client *slack.Client, p *ReportStatsParams) error
ReportStats messages a Slack channel with the stats for the last round of chat-roulette.
func RespondGreetMemberWebhook ¶
func RespondGreetMemberWebhook(ctx context.Context, client *http.Client, interaction *slack.InteractionCallback) error
RespondGreetMemberWebhook responds to the Slack webhook received when the "Opt In" button in the GREET_MEMBER message is clicked. The original message is updated to overwrite the button, so that it cannot be clicked multiple times.
func SyncChannels ¶
func SyncChannels(ctx context.Context, db *gorm.DB, client *slack.Client, p *SyncChannelsParams) error
SyncChannels ensures that there is no discrepancy between the Slack channels in the database and the Slack channels that the bot is a member of.
func SyncMembers ¶
func SyncMembers(ctx context.Context, db *gorm.DB, client *slack.Client, p *SyncMembersParams) error
SyncMembers ensures that there is no discrepancy between the members of Slack channels in the database and in Slack.
func UpdateChannel ¶
func UpdateChannel(ctx context.Context, db *gorm.DB, client *slack.Client, p *UpdateChannelParams) error
UpdateChannel updates the settings for a chat-roulette enabled Slack channel.
func UpdateMatch ¶
func UpdateMatch(ctx context.Context, db *gorm.DB, client *slack.Client, p *UpdateMatchParams) error
UpdateMatch updates the has_met status for a match at the end of a chat-roulette round.
func UpdateMember ¶
func UpdateMember(ctx context.Context, db *gorm.DB, client *slack.Client, p *UpdateMemberParams) error
UpdateMember updates the participation status for a member of a Slack channel.
func UpsertMemberCalendlyLink ¶
func UpsertMemberCalendlyLink(ctx context.Context, db *gorm.DB, interaction *slack.InteractionCallback) error
UpsertMemberCalendlyLink collects a new member's Calendly link during the onboarding flow and updates it in the database.
func UpsertMemberLocationInfo ¶
func UpsertMemberLocationInfo(ctx context.Context, db *gorm.DB, interaction *slack.InteractionCallback) error
UpsertMemberLocationInfo collects a new member's location info during the onboarding flow and updates it in the database.
func UpsertMemberProfileInfo ¶
func UpsertMemberProfileInfo(ctx context.Context, db *gorm.DB, interaction *slack.InteractionCallback) error
UpsertMemberProfileInfo collects a new member's profile info during the onboarding flow and updates it in the database.
func UpsertMemberTimezoneInfo ¶
func UpsertMemberTimezoneInfo(ctx context.Context, db *gorm.DB, interaction *slack.InteractionCallback) error
UpsertMemberTimezoneInfo collects a new member's timezone info during the onboarding flow and updates it in the database.
func ValidateMemberCalendlyLink ¶
ValidateMemberCalendlyLink validates that the user-provided Calendly link is a valid.
Note: providing a Calendly link is optional.
func ValidateMemberProfileInfo ¶
func ValidateMemberProfileInfo(ctx context.Context, interaction *slack.InteractionCallback) error
ValidateMemberProfileInfo validates that the user provided social profile link is a valid URL for the supported social profile types.
Types ¶
type AddChannelParams ¶
type AddChannelParams struct { ChannelID string `json:"channel_id"` Invitor string `json:"invitor"` Interval string `json:"interval"` Weekday string `json:"weekday"` Hour int `json:"hour"` NextRound time.Time `json:"next_round"` }
AddChannelParams are the parameters for the ADD_CHANNEL job.
type AddMemberParams ¶
AddMemberParams are the parameters for the ADD_MEMBER job.
type AppHomeParams ¶
AppHomeParams is the parameters for handling app_home_opened events
type ChatRoulettePair ¶
ChatRoulettePair is a pair of participants for chat-roulette
type CheckPairParams ¶
type CheckPairParams struct { ChannelID string `json:"channel_id"` NextRound time.Time `json:"next_round"` MatchID int32 `json:"match_id"` Participant string `json:"participant"` Partner string `json:"partner"` MpimID string `json:"mpim_id"` }
CheckPairParams are the parameters for the CHECK_PAIR job.
type CreateMatchesParams ¶
type CreateMatchesParams struct { ChannelID string `json:"channel_id"` RoundID int32 `json:"round_id"` }
CreateMatchesParams are the parameters for the CREATE_MATCHES job.
type CreatePairParams ¶
type CreatePairParams struct { ChannelID string `json:"channel_id"` MatchID int32 `json:"match_id"` Participant string `json:"participant"` Partner string `json:"partner"` }
CreatePairParams are the parameters for the CREATE_PAIR job.
type CreateRoundParams ¶
type CreateRoundParams struct { ChannelID string `json:"channel_id"` NextRound time.Time `json:"next_round"` Interval string }
CreateRoundParams are the parameters for the CREATE_ROUND job.
type DeleteChannelParams ¶
type DeleteChannelParams struct {
ChannelID string `json:"channel_id"`
}
DeleteChannelParams are the parameters for the DELETE_CHANNEL job.
type DeleteMemberParams ¶
type DeleteMemberParams struct { ChannelID string `json:"channel_id"` UserID string `json:"user_id"` }
DeleteMemberParams are the parameters for the DELETE_MEMBER job.
type EndRoundParams ¶
type EndRoundParams struct { ChannelID string `json:"channel_id"` NextRound time.Time `json:"next_round"` }
EndRoundParams are the parameters for the END_ROUND job.
type GreetMemberParams ¶
type GreetMemberParams struct { ChannelID string `json:"channel_id"` UserID string `json:"user_id"` }
GreetMemberParams are the parameters for the GREET_MEMBER job.
type NotifyPairParams ¶
type NotifyPairParams struct { ChannelID string `json:"channel_id"` MatchID int32 `json:"match_id"` Participant string `json:"participant"` Partner string `json:"partner"` }
NotifyPairParams are the parameters for the NOTIFY_PAIR job.
type ReportStatsParams ¶
type ReportStatsParams struct { ChannelID string `json:"channel_id"` RoundID int32 `json:"round_id"` NextRound time.Time `json:"next_round"` }
ReportStatsParams are the parameters for the REPORT_STATS job.
type SyncChannelsParams ¶
type SyncChannelsParams struct { BotUserID string `json:"bot_user_id"` ChatRouletteConfig config.ChatRouletteConfig `json:"config"` }
SyncChannelsParams are the parameters for SYNC_CHANNEL job.
type SyncMembersParams ¶
type SyncMembersParams struct {
ChannelID string `json:"channel_id"`
}
SyncMembersParams are the parameters for the SYNC_MEMBERS job.
type UpdateChannelParams ¶
type UpdateChannelParams struct { ChannelID string `json:"channel_id"` Interval string `json:"interval"` Weekday string `json:"weekday"` Hour int `json:"hour"` NextRound time.Time `json:"next_round"` }
UpdateChannelParams are the parameters the UPDATE_CHANNEL job.
type UpdateMatchParams ¶
UpdateMatchParams are the parameters for the UPDATE_MATCH job.
type UpdateMemberParams ¶
type UpdateMemberParams struct { ChannelID string `json:"channel_id"` UserID string `json:"user_id"` Country sqlcrypter.EncryptedBytes `json:"country,omitempty"` City sqlcrypter.EncryptedBytes `json:"city,omitempty"` Timezone sqlcrypter.EncryptedBytes `json:"timezone,omitempty"` ProfileType sqlcrypter.EncryptedBytes `json:"profile_type,omitempty"` ProfileLink sqlcrypter.EncryptedBytes `json:"profile_link,omitempty"` CalendlyLink sqlcrypter.EncryptedBytes `json:"calendly_link,omitempty"` IsActive bool `json:"is_active"` }
UpdateMemberParams are the parameters for the UPDATE_MEMBER job.
Source Files ¶
- bot_user.go
- channels.go
- event_app_home.go
- job_add_channel.go
- job_add_member.go
- job_check_pair.go
- job_create_matches.go
- job_create_pair.go
- job_create_round.go
- job_delete_channel.go
- job_delete_member.go
- job_end_round.go
- job_greet_member.go
- job_notify_pair.go
- job_report_stats.go
- job_sync_channels.go
- job_sync_members.go
- job_update_channel.go
- job_update_match.go
- job_update_member.go
- jobs.go
- match.go
- messages.go
- schedule.go
- template.go
- waiter.go