fb

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// NPSResponseCollectionName firestore collection name where nps responses are stored
	NPSResponseCollectionName = "nps_response"

	//RecordSurveyFeedbackResponseCollectionName firestore collection name where survey responses are stored
	RecordSurveyFeedbackResponseCollectionName = "patient_feedback_response"
)

Variables

This section is empty.

Functions

func SetDefaultActions

func SetDefaultActions(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	repository Repository,
) ([]feedlib.Action, error)

SetDefaultActions ensures that a feed has default actions

func SetDefaultItems

func SetDefaultItems(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	repository Repository,
) ([]feedlib.Item, error)

SetDefaultItems ensures that a feed has default feed items

func SetDefaultNudges

func SetDefaultNudges(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	repository Repository,
) ([]feedlib.Nudge, error)

SetDefaultNudges ensures that a feed has default nudges

func TruncateStringWithEllipses

func TruncateStringWithEllipses(str string, length int) string

TruncateStringWithEllipses truncates a string at the indicated length and adds trailing ellipses

Types

type Repository

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

Repository accesses and updates a feed that is stored on Firebase

func NewFirebaseRepository

func NewFirebaseRepository(
	ctx context.Context,
) (*Repository, error)

NewFirebaseRepository initializes a Firebase repository

func (Repository) DeleteAction

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

DeleteAction deletes an action from a user's feed

func (Repository) DeleteFeedItem

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

DeleteFeedItem deletes a nudge from a user's feed

func (Repository) DeleteMessage

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

DeleteMessage removes a specific message

func (Repository) DeleteNudge

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

DeleteNudge deletes a nudge from a user's feed

func (Repository) GetAction

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

GetAction retrieves a single action

func (Repository) GetActions

func (fr Repository) GetActions(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
) ([]feedlib.Action, error)

GetActions retrieves the actions that a single feed has

func (Repository) GetDefaultNudgeByTitle

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

GetDefaultNudgeByTitle returns a default nudge given its title

func (Repository) GetFeed

func (fr Repository) 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 by the user's ID and product flavour

Feed items are ordered by:

  1. Timestamp
  2. Sequence number
  3. ID (a tie breaker, in the unlikely event that the first two tie)

Having established this ordering, we will implement very lightweight pagination using a start and end offset.

This function is intended to be used for initial fetches of the inbox and manual refreshes. The clients are expected to implement logic to handle streaming inbox updates.

The return parameters are:

  1. A valid feed
  2. The number of feed items that MATCHED this query (ignoring pagination)
  3. The number of feed items that are NOT HIDDEN and are PENDING ACTION
  4. An error, if any

func (Repository) GetFeedItem

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

GetFeedItem retrieves and returns a single feed item

func (Repository) GetItems

func (fr Repository) GetItems(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	persistent feedlib.BooleanFilter,
	status *feedlib.Status,
	visibility *feedlib.Visibility,
	expired *feedlib.BooleanFilter,
	filterParams *helpers.FilterParams,
) ([]feedlib.Item, error)

GetItems fetches feed items

func (Repository) GetMessage

func (fr Repository) GetMessage(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
	messageID string,
) (*feedlib.Message, error)

GetMessage retrieves a message

func (Repository) GetMessages

func (fr Repository) GetMessages(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	itemID string,
) ([]feedlib.Message, error)

GetMessages gets the conversation thread for a single item

func (Repository) GetNudge

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

GetNudge retrieves a single nudge

func (Repository) GetNudges

func (fr Repository) GetNudges(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	status *feedlib.Status,
	visibility *feedlib.Visibility,
	expired *feedlib.BooleanFilter,
) ([]feedlib.Nudge, error)

GetNudges fetches nudges from the database

func (Repository) Labels

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

Labels retrieves the labels

func (Repository) PostMessage

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

PostMessage adds a message or reply to an item's thread

func (Repository) RecordSurveyFeedbackResponse added in v0.0.38

func (fr Repository) RecordSurveyFeedbackResponse(
	ctx context.Context,
	response *domain.SurveyFeedbackResponse,
) error

RecordSurveyFeedbackResponse stores the feedback responses

func (Repository) RetrieveNotification

func (fr Repository) RetrieveNotification(
	ctx context.Context,
	firestoreClient *firestore.Client,
	registrationToken string,
	newerThan time.Time,
	limit int,
) ([]*dto.SavedNotification, error)

RetrieveNotification retrieves a notification

func (Repository) SaveAction

func (fr Repository) SaveAction(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	action *feedlib.Action,
) (*feedlib.Action, error)

SaveAction saves a modified action It's expected to have an ID and sequence number already. One suggestion is to use UUIDs for IDs and UTC Unix Epoch seconds for sequence numbers.

func (Repository) SaveFeedItem

func (fr Repository) SaveFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	item *feedlib.Item,
) (*feedlib.Item, error)

SaveFeedItem validates and saves a feed item. It's expected to have an ID and sequence number already. One suggestion is to use UUIDs for IDs and UTC Unix Epoch seconds for sequence numbers.

func (Repository) SaveIncomingEvent

func (fr Repository) SaveIncomingEvent(
	ctx context.Context,
	event *feedlib.Event,
) error

SaveIncomingEvent saves events that have been received from clients before they are processed further

func (Repository) SaveLabel

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

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

func (Repository) SaveNPSResponse

func (fr Repository) SaveNPSResponse(
	ctx context.Context,
	response *dto.NPSResponse,
) error

SaveNPSResponse stores the nps responses

func (Repository) SaveNotification

func (fr Repository) SaveNotification(
	ctx context.Context,
	firestoreClient *firestore.Client,
	notification dto.SavedNotification,
) error

SaveNotification saves a notification

func (Repository) SaveNudge

func (fr Repository) SaveNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudge *feedlib.Nudge,
) (*feedlib.Nudge, error)

SaveNudge saves an updated nudge It's expected to have an ID and sequence number already. One suggestion is to use UUIDs for IDs and UTC Unix Epoch seconds for sequence numbers.

func (Repository) SaveOutgoingEmails

func (fr Repository) SaveOutgoingEmails(
	ctx context.Context,
	payload *dto.OutgoingEmailsLog,
) error

SaveOutgoingEmails saves all the outgoing emails

func (Repository) SaveOutgoingEvent

func (fr Repository) SaveOutgoingEvent(
	ctx context.Context,
	event *feedlib.Event,
) error

SaveOutgoingEvent saves events that are to be sent to clients before they are sent

func (Repository) SaveTwilioResponse

func (fr Repository) SaveTwilioResponse(
	ctx context.Context,
	data dto.Message,
) error

SaveTwilioResponse saves the callback data

func (Repository) SaveTwilioVideoCallbackStatus

func (fr Repository) SaveTwilioVideoCallbackStatus(
	ctx context.Context,
	data dto.CallbackData,
) error

SaveTwilioVideoCallbackStatus saves the callback data

func (Repository) UnreadPersistentItems

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

UnreadPersistentItems fetches unread persistent items

func (Repository) UpdateFeedItem

func (fr Repository) UpdateFeedItem(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	item *feedlib.Item,
) (*feedlib.Item, error)

UpdateFeedItem updates an existing feed item

func (Repository) UpdateMailgunDeliveryStatus

func (fr Repository) UpdateMailgunDeliveryStatus(
	ctx context.Context,
	payload *dto.MailgunEvent,
) (*dto.OutgoingEmailsLog, error)

UpdateMailgunDeliveryStatus updates the status and delivery time of the sent email message

func (Repository) UpdateNudge

func (fr Repository) UpdateNudge(
	ctx context.Context,
	uid string,
	flavour feedlib.Flavour,
	nudge *feedlib.Nudge,
) (*feedlib.Nudge, error)

UpdateNudge updates an existing nudge e.g to show or hide it

func (Repository) UpdateUnreadPersistentItemsCount

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

UpdateUnreadPersistentItemsCount updates the unread inbox count

Jump to

Keyboard shortcuts

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