activity

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotificationTypeUnknown = iota
	NotificationTypeWelcomeBonus
	NotificationTypeWeeklyBonus
	NotificationTypeCreateGroup
	NotificationTypeSendListenerMessage
	NotificationTypeSendTip
	NotificationTypeReceivedTip
	NotificationTypePromotedToSpeaker
)

Variables

View Source
var (
	ErrInvalidActivityFeedType = errors.New("activity feed type not supported")
	ErrInvalidNotificationType = errors.New("notification type not supported")
)

Functions

func GetNotificationID

func GetNotificationID(notificationType NotificationType, userID *commonpb.UserId, additionalSeeds ...[]byte) (*activitypb.NotificationId, error)

func InjectLocalizedText

func InjectLocalizedText(ctx context.Context, notification *activitypb.Notification) error

func NotificationIDString

func NotificationIDString(id *activitypb.NotificationId) string

func SendNotification

func SendNotification(ctx context.Context, activityFeeds Store, activityFeedType activitypb.ActivityFeedType, userID *commonpb.UserId, builder NotificationBuilder) (*activitypb.Notification, error)

SendNotification sends a notification to a user's activity feed

Types

type NotificationBuilder

type NotificationBuilder func() (*activitypb.Notification, error)

func NewCreateGroupNotificationBuilder

func NewCreateGroupNotificationBuilder(ctx context.Context, userID *commonpb.UserId, chatID *commonpb.ChatId, quarks uint64, ts time.Time) NotificationBuilder

func NewPromotedToSpeakerNotificationBuilder

func NewPromotedToSpeakerNotificationBuilder(ctx context.Context, promotee, promoter *commonpb.UserId, chatID *commonpb.ChatId, ts time.Time) NotificationBuilder

func NewReceivedTipNotificationBuilder

func NewReceivedTipNotificationBuilder(ctx context.Context, userID *commonpb.UserId, chatID *commonpb.ChatId, messageID *messagingpb.MessageId, quarks uint64, ts time.Time) NotificationBuilder

func NewSendListenerMessageNotificationBuilder

func NewSendListenerMessageNotificationBuilder(ctx context.Context, userID *commonpb.UserId, chatID *commonpb.ChatId, messageID *messagingpb.MessageId, quarks uint64, ts time.Time) NotificationBuilder

func NewSendTipNotificationBuilder

func NewSendTipNotificationBuilder(ctx context.Context, userID *commonpb.UserId, chatID *commonpb.ChatId, messageID *messagingpb.MessageId, quarks uint64, ts time.Time) NotificationBuilder

func NewWeeklyBonusNotificationBuilder

func NewWeeklyBonusNotificationBuilder(ctx context.Context, userID *commonpb.UserId, quarks uint64, ts time.Time) NotificationBuilder

func NewWelcomeBonusNotificationBuilder

func NewWelcomeBonusNotificationBuilder(ctx context.Context, userID *commonpb.UserId, quarks uint64, ts time.Time) NotificationBuilder

type NotificationType

type NotificationType uint32

type Server

type Server struct {
	activitypb.UnimplementedActivityFeedServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(
	log *zap.Logger,
	authz auth.Authorizer,
	activityFeeds Store,
) *Server

type Store

type Store interface {
	// SaveNotification inserts or updates a notification depending on whether
	// the notification supports grouping
	SaveNotification(ctx context.Context, activityFeedType activitypb.ActivityFeedType, userID *commonpb.UserId, notification *activitypb.Notification) (*activitypb.Notification, error)

	// GetLatestNotifications gets the latest N notifications for a user's
	// activity feed type
	GetLatestNotifications(ctx context.Context, activityFeedType activitypb.ActivityFeedType, userID *commonpb.UserId, limit int) ([]*activitypb.Notification, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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