workflows

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultReminderTime = "8:00AM"
)

Variables

View Source
var Schedules = []string{
	"slack.schedules.reminders",
}

Schedules is a list of workflow names that RevChat runs periodically via Temporal schedules (https://docs.temporal.io/develop/go/schedules).

View Source
var Signals = []string{
	"slack.events.app_rate_limited",

	"slack.events.channel_archive",
	"slack.events.group_archive",
	"slack.events.member_joined_channel",
	"slack.events.member_left_channel",
	"slack.events.message",
	"slack.events.reaction_added",
	"slack.events.reaction_removed",

	"slack.events.slash_command",
}

Signals is a list of signal names that RevChat receives from Timpani, to trigger event handling workflows.

This is based on:

Functions

func CreateSchedule

func CreateSchedule(ctx context.Context, c client.Client, taskQueue string)

CreateSchedule starts a scheduled workflow that runs every 30 minutes, to send daily reminders.

func DrainSignals

func DrainSignals(ctx workflow.Context) bool

DrainSignals drains all pending Signals channels, and waits for their corresponding workflow executions to complete in order. This is called in preparation for resetting the dispatcher workflow's history.

func ReactionAddedWorkflow

func ReactionAddedWorkflow(ctx workflow.Context, event reactionEventWrapper) error

ReactionAddedWorkflow mirrors the addition of a reaction to a Slack message in the corresponding PR comment: https://docs.slack.dev/reference/events/reaction_added/

func ReactionRemovedWorkflow

func ReactionRemovedWorkflow(ctx workflow.Context, event reactionEventWrapper) error

ReactionRemovedWorkflow mirrors the removal of a reaction from a Slack message in the corresponding PR comment: https://docs.slack.dev/reference/events/reaction_removed/

func RegisterSignals

func RegisterSignals(ctx workflow.Context, sel workflow.Selector)

RegisterSignals routes Signals to their registered workflows.

func RegisterWorkflows

func RegisterWorkflows(ctx context.Context, cmd *cli.Command, w worker.Worker)

RegisterWorkflows maps event-handling workflow functions to Signals.

Types

type Config

type Config struct {
	AlertsChannel string
	NudgeChannels []string
	NudgeGroups   []string

	BitbucketWorkspace string

	ThrippyGRPCAddress string
	ThrippyHTTPAddress string

	ThrippyLinksTemplate string
	// contains filtered or unexported fields
}

func (*Config) AppRateLimitedWorkflow added in v1.3.2

func (c *Config) AppRateLimitedWorkflow(ctx workflow.Context, event map[string]any) error

AppRateLimitedWorkflow highlights Slack rate-limiting events:

func (*Config) ChannelArchivedWorkflow added in v1.3.2

func (c *Config) ChannelArchivedWorkflow(ctx workflow.Context, event archiveEventWrapper) error

ChannelArchivedWorkflow handles PR data cleanups after unexpected Slack archiving events, so RevChat will not try to modify or post messages to archived channels:

func (*Config) MemberJoinedWorkflow added in v1.3.2

func (c *Config) MemberJoinedWorkflow(ctx workflow.Context, event memberEventWrapper) error

MemberJoinedWorkflow ensures that users who are added to RevChat channels by others are opted-in: https://docs.slack.dev/reference/events/member_joined_channel/

func (*Config) MemberLeftWorkflow added in v1.3.2

func (c *Config) MemberLeftWorkflow(ctx workflow.Context, event memberEventWrapper) error

MemberLeftWorkflow is (or rather will be) based on: https://docs.slack.dev/reference/events/member_left_channel/

func (*Config) MessageWorkflow

func (c *Config) MessageWorkflow(ctx workflow.Context, event messageEventWrapper) error

MessageWorkflow mirrors Slack message creation/editing/deletion events as/in PR comments: https://docs.slack.dev/reference/events/message/

func (*Config) OptInSlashCommand

func (c *Config) OptInSlashCommand(ctx workflow.Context, event commands.SlashCommandEvent) error

OptInSlashCommand directs the user to authorize RevChat to act on their behalf in the configured SCM (Bitbucket or GitHub) using an OAuth 2.0 3-legged flow, and saves or updates their details in RevChat's user database.

This function is in the "workflows" package instead of "commands" because it requires the Thrippy details in Config, and starts a child workflow to wait for the OAuth flow to complete.

func (*Config) OptOutSlashCommand

func (c *Config) OptOutSlashCommand(ctx workflow.Context, event commands.SlashCommandEvent) error

func (*Config) RemindersWorkflow added in v1.3.2

func (c *Config) RemindersWorkflow(ctx workflow.Context) error

func (*Config) SlashCommandWorkflow

func (c *Config) SlashCommandWorkflow(ctx workflow.Context, event commands.SlashCommandEvent) error

SlashCommandWorkflow routes user command events to their respective handlers in the commands package:

type Edited

type Edited struct {
	User string `json:"user"`
	TS   string `json:"ts"`
}

type File

type File struct {
	ID string `json:"id"`

	Name       string `json:"name"`
	Title      string `json:"title"`
	MimeType   string `json:"mimetype"`
	FileType   string `json:"filetype"` // https://docs.slack.dev/reference/objects/file-object#types
	PrettyType string `json:"pretty_type"`

	Size      int `json:"size"`
	OriginalW int `json:"original_w"`
	OriginalH int `json:"original_h"`

	Mode             string `json:"mode"` // One of: "hosted", "external", "snippet", or "post".
	Editable         bool   `json:"editable"`
	IsExternal       bool   `json:"is_external"`
	IsPublic         bool   `json:"is_public"`
	PublicURLShared  bool   `json:"public_url_shared"`
	ExternalType     string `json:"external_type"`
	MediaDisplayType string `json:"media_display_type"`

	Username     string `json:"username"`
	DisplayAsBot bool   `json:"display_as_bot"`

	URLPrivate         string `json:"url_private"`
	URLPrivateDownload string `json:"url_private_download"`
	Permalink          string `json:"permalink"`
	PermalinkPublic    string `json:"permalink_public"`
	EditLink           string `json:"edit_link,omitempty"`

	Thumb64     string `json:"thumb_64,omitempty"`
	Thumb80     string `json:"thumb_80,omitempty"`
	Thumb160    string `json:"thumb_160,omitempty"`
	Thumb360    string `json:"thumb_360,omitempty"`
	Thumb360Gif string `json:"thumb_360_gif,omitempty"`
	Thumb480    string `json:"thumb_480,omitempty"`
	Thumb720    string `json:"thumb_720,omitempty"`
	Thumb800    string `json:"thumb_800,omitempty"`
	Thumb960    string `json:"thumb_960,omitempty"`
	Thumb1024   string `json:"thumb_1024,omitempty"`
	ThumbTiny   string `json:"thumb_tiny,omitempty"`

	Preview            string `json:"preview,omitempty"`
	PreviewHighlight   string `json:"preview_highlight,omitempty"`
	PreviewIsTruncated bool   `json:"preview_is_truncated,omitempty"`
	Lines              int    `json:"lines,omitempty"`
	LinesMore          int    `json:"lines_more,omitempty"`

	SkippedShares  bool   `json:"skipped_shares,omitempty"`
	HasRichPreview bool   `json:"has_rich_preview,omitempty"`
	FileAccess     string `json:"file_access,omitempty"`
}

https://docs.slack.dev/reference/events/message/file_share https://docs.slack.dev/reference/objects/file-object

type MemberEvent

type MemberEvent struct {
	Enterprise  string `json:"enterprise,omitempty"`
	Team        string `json:"team"`
	Channel     string `json:"channel"`
	ChannelType string `json:"channel_type"`
	User        string `json:"user"`

	Inviter string `json:"inviter,omitempty"`
}

https://docs.slack.dev/reference/events/member_joined_channel/ https://docs.slack.dev/reference/events/member_left_channel/

type MessageEvent

type MessageEvent struct {
	Subtype string `json:"subtype,omitempty"`

	User     string `json:"user,omitempty"`
	BotID    string `json:"bot_id,omitempty"`
	Username string `json:"username,omitempty"` // Customized display name, when bot_id is present.

	Team       string `json:"team,omitempty"`
	SourceTeam string `json:"source_team,omitempty"`
	UserTeam   string `json:"user_team,omitempty"`

	Channel     string `json:"channel,omitempty"`
	ChannelType string `json:"channel_type,omitempty"`

	Text   string           `json:"text,omitempty"`
	Blocks []map[string]any `json:"blocks,omitempty"`

	Edited          *Edited       `json:"edited,omitempty"`           // Subtype = "message_changed".
	Message         *MessageEvent `json:"message,omitempty"`          // Subtype = "message_changed".
	PreviousMessage *MessageEvent `json:"previous_message,omitempty"` // Subtype = "message_changed" or "message_deleted".
	Root            *MessageEvent `json:"root,omitempty"`             // Subtype = "thread_broadcast".

	TS        string `json:"ts"`
	EventTS   string `json:"event_ts,omitempty"`
	DeletedTS string `json:"deleted_ts,omitempty"` // Subtype = "message_deleted".
	ThreadTS  string `json:"thread_ts,omitempty"`  // Reply, or subtype = "thread_broadcast".

	LatestReply     string   `json:"latest_reply,omitempty"`
	ReplyCount      int      `json:"reply_count,omitempty"`
	ReplyUsers      []string `json:"reply_users,omitempty"`
	ReplyUsersCount int      `json:"reply_users_count,omitempty"`

	// https://docs.slack.dev/reference/events/message/file_share
	Files        []File `json:"files,omitempty"`
	Upload       bool   `json:"upload,omitempty"`
	DisplayAsBot bool   `json:"display_as_bot,omitempty"`

	// https://docs.slack.dev/reference/events/message/#stars
	IsStarred bool       `json:"is_starred,omitempty"`
	PinnedTo  []string   `json:"pinned_to,omitempty"`
	Reactions []Reaction `json:"reactions,omitempty"`
}

https://docs.slack.dev/reference/events/message/

type Reaction

type Reaction struct {
	Name  string   `json:"name,omitempty"`
	Users []string `json:"users,omitempty"`
	Count int      `json:"count,omitempty"`
}

https://docs.slack.dev/reference/events/message/#stars

type ReactionEvent

type ReactionEvent struct {
	User     string `json:"user"`
	Reaction string `json:"reaction"`

	Item struct {
		Type        string `json:"type"`
		Channel     string `json:"channel,omitempty"`
		TS          string `json:"ts,omitempty"`
		File        string `json:"file,omitempty"`
		FileComment string `json:"file_comment,omitempty"`
	} `json:"item"`

	ItemUser string `json:"item_user,omitempty"`

	EventTS string `json:"event_ts"`
}

https://docs.slack.dev/reference/events/reaction_added/ https://docs.slack.dev/reference/events/reaction_removed/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL