feed

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlePubsubPayload

type HandlePubsubPayload func(ctx context.Context, m *pubsubtools.PubSubPayload) error

HandlePubsubPayload defines the signature of a function that handles payloads received from Google Cloud Pubsub

type NotificationImpl

type NotificationImpl struct {
	// contains filtered or unexported fields
}

NotificationImpl represents the notification usecase implementation

func NewNotification

func NewNotification(infrastructure infrastructure.Interactor) *NotificationImpl

NewNotification initializes a notification usecase

func (NotificationImpl) GetUserTokens

func (n NotificationImpl) GetUserTokens(
	ctx context.Context,
	uids []string,
) ([]string, error)

GetUserTokens retrieves the user tokens corresponding to the supplied UIDs

func (NotificationImpl) HandleActionDelete

func (n NotificationImpl) HandleActionDelete(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleActionDelete responds to action publish messages

func (NotificationImpl) HandleActionPublish

func (n NotificationImpl) HandleActionPublish(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleActionPublish responds to action publish messages

func (NotificationImpl) HandleIncomingEvent

func (n NotificationImpl) HandleIncomingEvent(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleIncomingEvent responds to message delete pubsub messages

func (NotificationImpl) HandleItemDelete

func (n NotificationImpl) HandleItemDelete(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleItemDelete responds to item delete messages

func (NotificationImpl) HandleItemHide

func (n NotificationImpl) HandleItemHide(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleItemHide responds to item hide messages

func (NotificationImpl) HandleItemPin

func (n NotificationImpl) HandleItemPin(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleItemPin responds to item pin messages

func (NotificationImpl) HandleItemPublish

func (n NotificationImpl) HandleItemPublish(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleItemPublish responds to item publish messages

func (NotificationImpl) HandleItemResolve

func (n NotificationImpl) HandleItemResolve(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleItemResolve responds to item resolve messages

func (NotificationImpl) HandleItemShow

func (n NotificationImpl) HandleItemShow(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleItemShow responds to item show messages

func (NotificationImpl) HandleItemUnpin

func (n NotificationImpl) HandleItemUnpin(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleItemUnpin responds to item unpin messages

func (NotificationImpl) HandleItemUnresolve

func (n NotificationImpl) HandleItemUnresolve(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleItemUnresolve responds to item unresolve messages

func (NotificationImpl) HandleMessageDelete

func (n NotificationImpl) HandleMessageDelete(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleMessageDelete responds to message delete pubsub messages

func (NotificationImpl) HandleMessagePost

func (n NotificationImpl) HandleMessagePost(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleMessagePost responds to message post pubsub messages

func (NotificationImpl) HandleNudgeDelete

func (n NotificationImpl) HandleNudgeDelete(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleNudgeDelete responds to nudge delete messages

func (NotificationImpl) HandleNudgeHide

func (n NotificationImpl) HandleNudgeHide(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleNudgeHide responds to nudge hide messages

func (NotificationImpl) HandleNudgePublish

func (n NotificationImpl) HandleNudgePublish(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleNudgePublish responds to nudge publish messages

func (NotificationImpl) HandleNudgeResolve

func (n NotificationImpl) HandleNudgeResolve(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleNudgeResolve responds to nudge resolve messages

func (NotificationImpl) HandleNudgeShow

func (n NotificationImpl) HandleNudgeShow(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleNudgeShow responds to nudge hide messages

func (NotificationImpl) HandleNudgeUnresolve

func (n NotificationImpl) HandleNudgeUnresolve(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleNudgeUnresolve responds to nudge unresolve messages

func (NotificationImpl) HandleSendNotification

func (n NotificationImpl) HandleSendNotification(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

HandleSendNotification responds to send notification messages

func (NotificationImpl) NotifyInboxCountUpdate

func (n NotificationImpl) NotifyInboxCountUpdate(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	count int,
) error

NotifyInboxCountUpdate sends a message notifying of an update to inbox item counts.

func (NotificationImpl) NotifyItemUpdate

func (n NotificationImpl) NotifyItemUpdate(
	ctx context.Context,
	sender string,
	includeNotification bool,
	m *pubsubtools.PubSubPayload,
) error

NotifyItemUpdate sends a Firebase Cloud Messaging notification

func (NotificationImpl) NotifyNudgeUpdate

func (n NotificationImpl) NotifyNudgeUpdate(
	ctx context.Context,
	sender string,
	m *pubsubtools.PubSubPayload,
) error

NotifyNudgeUpdate sends a nudge update notification via FCM

func (NotificationImpl) SendNotificationEmail added in v0.0.18

func (n NotificationImpl) SendNotificationEmail(
	ctx context.Context,
	m *pubsubtools.PubSubPayload,
) error

SendNotificationEmail sends an email

func (NotificationImpl) SendNotificationViaFCM

func (n NotificationImpl) SendNotificationViaFCM(
	ctx context.Context,
	uids []string,
	sender string,
	pl dto.NotificationEnvelope,
	notification *firebasetools.FirebaseSimpleNotificationInput,
) error

SendNotificationViaFCM publishes an FCM notification

func (NotificationImpl) UpdateInbox

func (n NotificationImpl) UpdateInbox(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
) error

UpdateInbox recalculates the inbox count and notifies the client over FCM

type NotificationUsecases

type NotificationUsecases interface {
	HandleItemPublish(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleItemDelete(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleItemResolve(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleItemUnresolve(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleItemHide(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleItemShow(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleItemPin(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleItemUnpin(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleNudgePublish(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleNudgeDelete(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleNudgeResolve(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleNudgeUnresolve(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleNudgeHide(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleNudgeShow(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleActionPublish(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleActionDelete(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleMessagePost(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleMessageDelete(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	HandleIncomingEvent(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	NotifyItemUpdate(
		ctx context.Context,
		sender string,
		includeNotification bool,
		m *pubsubtools.PubSubPayload,
	) error

	UpdateInbox(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
	) error

	NotifyNudgeUpdate(
		ctx context.Context,
		sender string,
		m *pubsubtools.PubSubPayload,
	) error

	NotifyInboxCountUpdate(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		count int,
	) error

	GetUserTokens(
		ctx context.Context,
		uids []string,
	) ([]string, error)

	SendNotificationViaFCM(
		ctx context.Context,
		uids []string,
		sender string,
		pl dto.NotificationEnvelope,
		notification *firebasetools.FirebaseSimpleNotificationInput,
	) error

	HandleSendNotification(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error

	SendNotificationEmail(
		ctx context.Context,
		m *pubsubtools.PubSubPayload,
	) error
}

NotificationUsecases represent logic required to make notification

type UseCaseImpl

type UseCaseImpl struct {
	// contains filtered or unexported fields
}

UseCaseImpl represents the feed usecase implementation

func NewFeed

func NewFeed(
	infrastructure infrastructure.Interactor,
) *UseCaseImpl

NewFeed initializes a user feed

func (UseCaseImpl) DeleteAction

func (fe UseCaseImpl) DeleteAction(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	actionID string,
) error

DeleteAction removes a nudge

func (UseCaseImpl) DeleteFeedItem

func (fe UseCaseImpl) DeleteFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
) error

DeleteFeedItem removes a feed item

func (UseCaseImpl) DeleteMessage

func (fe UseCaseImpl) DeleteMessage(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
	messageID string,
) error

DeleteMessage permanently removes a message

func (UseCaseImpl) DeleteNudge

func (fe UseCaseImpl) DeleteNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudgeID string,
) error

DeleteNudge removes a nudge

func (UseCaseImpl) GetAction

func (fe UseCaseImpl) GetAction(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	actionID string,
) (*feedlib.Action, error)

GetAction retrieves a feed item

func (UseCaseImpl) GetDefaultNudgeByTitle

func (fe UseCaseImpl) GetDefaultNudgeByTitle(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	title string,
) (*feedlib.Nudge, error)

GetDefaultNudgeByTitle retrieves a default feed nudge

func (UseCaseImpl) GetFeed

func (fe UseCaseImpl) GetFeed(
	ctx context.Context,
	uid *string,
	isAnonymous *bool,
	flavour feedlib.Flavour,
	playMP4 bool,
	persistent feedlib.BooleanFilter,
	status *feedlib.Status,
	visibility *feedlib.Visibility,
	expired *feedlib.BooleanFilter,
	filterParams *helpers.FilterParams,
) (*domain.Feed, error)

GetFeed retrieves a feed

func (UseCaseImpl) GetFeedItem

func (fe UseCaseImpl) GetFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
) (*feedlib.Item, error)

GetFeedItem retrieves a feed item

func (UseCaseImpl) GetNudge

func (fe UseCaseImpl) GetNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudgeID string,
) (*feedlib.Nudge, error)

GetNudge retrieves a feed item

func (UseCaseImpl) GetThinFeed

func (fe UseCaseImpl) GetThinFeed(
	ctx context.Context,
	uid *string,
	isAnonymous *bool,
	flavour feedlib.Flavour,
) (*domain.Feed, error)

GetThinFeed gets a feed with only the UID, flavour and dependencies filled in.

It is used for efficient instantiation of feeds by code that does not need the full detail.

func (UseCaseImpl) HideFeedItem

func (fe UseCaseImpl) HideFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
) (*feedlib.Item, error)

HideFeedItem hides a feed item from a specific user's feed

func (UseCaseImpl) HideNudge

func (fe UseCaseImpl) HideNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudgeID string,
) (*feedlib.Nudge, error)

HideNudge hides a feed item from a specific user's feed

func (UseCaseImpl) Labels

func (fe UseCaseImpl) Labels(
	ctx context.Context,
	uid string, flavour feedlib.Flavour,
) ([]string, error)

Labels returns the valid labels / filters for this feed

func (UseCaseImpl) PinFeedItem

func (fe UseCaseImpl) PinFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
) (*feedlib.Item, error)

PinFeedItem marks a feed item as persistent

func (UseCaseImpl) PostMessage

func (fe UseCaseImpl) PostMessage(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
	message *feedlib.Message,
) (*feedlib.Message, error)

PostMessage updates a feed/thread with a new message OR a reply

func (UseCaseImpl) ProcessEvent

func (fe UseCaseImpl) ProcessEvent(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	event *feedlib.Event,
) error

ProcessEvent publishes an event to an incoming event channel.

Further processing is delegated to listeners to that event channel.

The results of processing an event include but are not limited to:

  1. Marking feed items as done and notifying their subscribers
  2. Marking nudges as done and notifying their subscribers
  3. Updating an audit trail
  4. Updating (streaming) analytics

func (UseCaseImpl) PublishAction

func (fe UseCaseImpl) PublishAction(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	action *feedlib.Action,
) (*feedlib.Action, error)

PublishAction adds/updates an action in a user's feed

If an action with the same ID existed but the sequence number of the new nudge is higher, the action is replaced.

If an action with that ID does not exist, it is inserted at the correct place.

If an action with that ID exists, and the existing sequence number is lower, it is updated.

If an action with that ID and sequence number already exists, the update is ignored. This makes the push method idempotent.

If the action does not have a sequence number, it is assigned one.

func (UseCaseImpl) PublishFeedItem

func (fe UseCaseImpl) PublishFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	item *feedlib.Item,
) (*feedlib.Item, error)

PublishFeedItem idempotently creates or updates a feed item

func (UseCaseImpl) PublishNudge

func (fe UseCaseImpl) PublishNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudge *feedlib.Nudge,
) (*feedlib.Nudge, error)

PublishNudge idempotently creates or updates a nudge

If a nudge with the same ID existed but the sequence number of the new nudge is higher, the nudge is replaced.

If a nudge with that ID does not exist, it is inserted at the correct place.

If a nudge with that ID exists, and the existing sequence number is lower, it is updated.

If a nudge with that ID and sequence number already exists, the update is ignored. This makes the push method idempotent.

If the nudge does not have a sequence number, it is assigned one.

func (UseCaseImpl) ResolveFeedItem

func (fe UseCaseImpl) ResolveFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
) (*feedlib.Item, error)

ResolveFeedItem marks a feed item as Done

func (UseCaseImpl) ResolveNudge

func (fe UseCaseImpl) ResolveNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudgeID string,
) (*feedlib.Nudge, error)

ResolveNudge marks a feed item as Done

func (UseCaseImpl) SaveLabel

func (fe UseCaseImpl) SaveLabel(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	label string,
) error

SaveLabel saves the indicated label, if it does not already exist

func (UseCaseImpl) ShowFeedItem

func (fe UseCaseImpl) ShowFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
) (*feedlib.Item, error)

ShowFeedItem shows a feed item on a specific user's feed

func (UseCaseImpl) ShowNudge

func (fe UseCaseImpl) ShowNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudgeID string,
) (*feedlib.Nudge, error)

ShowNudge hides a feed item from a specific user's feed

func (UseCaseImpl) UnpinFeedItem

func (fe UseCaseImpl) UnpinFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
) (*feedlib.Item, error)

UnpinFeedItem marks a feed item as not persistent

func (UseCaseImpl) UnreadPersistentItems

func (fe UseCaseImpl) UnreadPersistentItems(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
) (int, error)

UnreadPersistentItems returns the number of unread inbox items for this feed

func (UseCaseImpl) UnresolveFeedItem

func (fe UseCaseImpl) UnresolveFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
) (*feedlib.Item, error)

UnresolveFeedItem marks a feed item as pending

func (UseCaseImpl) UnresolveNudge

func (fe UseCaseImpl) UnresolveNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudgeID string,
) (*feedlib.Nudge, error)

UnresolveNudge marks a feed item as pending

func (UseCaseImpl) UpdateUnreadPersistentItemsCount

func (fe UseCaseImpl) UpdateUnreadPersistentItemsCount(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
) error

UpdateUnreadPersistentItemsCount updates the number of unread inbox items

type Usecases

type Usecases interface {
	GetFeed(
		ctx context.Context,
		uid *string,
		isAnonymous *bool,
		flavour feedlib.Flavour,
		playMP4 bool,
		persistent feedlib.BooleanFilter,
		status *feedlib.Status,
		visibility *feedlib.Visibility,
		expired *feedlib.BooleanFilter,
		filterParams *helpers.FilterParams,
	) (*domain.Feed, error)

	GetThinFeed(
		ctx context.Context,
		uid *string,
		isAnonymous *bool,
		flavour feedlib.Flavour,
	) (*domain.Feed, error)

	GetFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
	) (*feedlib.Item, error)

	GetNudge(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		nudgeID string,
	) (*feedlib.Nudge, error)

	GetAction(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		actionID string,
	) (*feedlib.Action, error)

	PublishFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		item *feedlib.Item,
	) (*feedlib.Item, error)

	DeleteFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
	) error

	ResolveFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
	) (*feedlib.Item, error)

	PinFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
	) (*feedlib.Item, error)

	UnpinFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
	) (*feedlib.Item, error)

	UnresolveFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
	) (*feedlib.Item, error)

	HideFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
	) (*feedlib.Item, error)

	ShowFeedItem(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
	) (*feedlib.Item, error)

	Labels(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
	) ([]string, error)

	SaveLabel(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		label string,
	) error

	UnreadPersistentItems(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
	) (int, error)

	UpdateUnreadPersistentItemsCount(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
	) error

	PublishNudge(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		nudge *feedlib.Nudge,
	) (*feedlib.Nudge, error)

	ResolveNudge(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		nudgeID string,
	) (*feedlib.Nudge, error)

	UnresolveNudge(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		nudgeID string,
	) (*feedlib.Nudge, error)

	HideNudge(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		nudgeID string,
	) (*feedlib.Nudge, error)

	ShowNudge(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		nudgeID string,
	) (*feedlib.Nudge, error)

	GetDefaultNudgeByTitle(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		title string,
	) (*feedlib.Nudge, error)

	ProcessEvent(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		event *feedlib.Event,
	) error

	DeleteMessage(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
		messageID string,

	) error

	PostMessage(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		itemID string,
		message *feedlib.Message,
	) (*feedlib.Message, error)

	DeleteAction(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		actionID string,
	) error

	PublishAction(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		action *feedlib.Action,
	) (*feedlib.Action, error)

	DeleteNudge(
		ctx context.Context,
		uid string,
		flavour feedlib.Flavour,
		nudgeID string,
	) error
}

Usecases represents all the profile business logic

Jump to

Keyboard shortcuts

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