async

package
v0.0.0-...-905e761 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenGeneral

func ListenGeneral(
	parentCtx context.Context,
	db *ent.Client,
	youTubeConfig *oauth2.Config,
	subscription *pubsub.Subscription,
	botTopic *pubsub.Topic,
	setChangeReason func(string),
) error

ListenGeneral polls a pubsub subscription for GeneralType messages.

func NewPubSubMembershipChangeHandler

func NewPubSubMembershipChangeHandler(ctx context.Context, topic *pubsub.Topic) membership.ChangeHandler

func ProcessUserDelete

func ProcessUserDelete(ctx context.Context, db *ent.Client, topic *pubsub.Topic, userID uint64, reason string) error

ProcessUserDelete revokes tokens and tells the bot to delete the user. The bot has to delete the user because it'll communicate the final role removals + user deletion, and at that point why have the async queue require another message?

func ProcessYouTubeDelete

func ProcessYouTubeDelete(ctx context.Context, db *ent.Client, topic *pubsub.Topic, userID uint64) error

ProcessUserDelete revokes tokens and deletes all membership edges.

func ProcessYouTubeRegistration

func ProcessYouTubeRegistration(ctx context.Context, db *ent.Client, youTubeConfig *oauth2.Config, userID uint64, setChangeReason func(string)) error

ProcessYouTubeRegistration really only checks memberships and triggers changes. One day it might do something else?

func PublishApplyMembershipMessage

func PublishApplyMembershipMessage(ctx context.Context, topic *pubsub.Topic, message ApplyMembershipPSMessage) error

func PublishGeneralMessage

func PublishGeneralMessage(ctx context.Context, topic *pubsub.Topic, message GeneralPSMessage) error

Types

type ApplyMembershipPSMessage

type ApplyMembershipPSMessage struct {
	ApplySingle  *ApplySingleMessage `json:",omitempty"`
	DeleteSingle *DeleteUserMessage  `json:",omitempty"`
	EnforceAll   *EnforceAllMessage  `json:",omitempty"`
}

type ApplySingleMessage

type ApplySingleMessage struct {
	UserMembershipID int
	Gained           bool
	Reason           string
}

type DeleteUserMessage

type DeleteUserMessage struct {
	UserID json.Number
	Reason string `json:",omitempty"`
}

type EnforceAllMessage

type EnforceAllMessage struct {
	DryRun bool
	Reason string
}

type GeneralPSMessage

type GeneralPSMessage struct {
	UserDelete          *DeleteUserMessage          `json:",omitempty"`
	YouTubeRegistration *YouTubeRegistrationMessage `json:",omitempty"`
	YouTubeDelete       json.Number                 `json:",omitempty"`
}

type PSMessageType

type PSMessageType string

PSMessageType is a Pub/Sub message type enum, packed into the attributes field.

const (
	GeneralType         PSMessageType = "general"
	ApplyMembershipType PSMessageType = "apply-membership"
)

type YouTubeRegistrationMessage

type YouTubeRegistrationMessage struct {
	UserID json.Number
}

Jump to

Keyboard shortcuts

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