notificationsrepo

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdditionalInfoKeyExpiresAt = "expires_at"
)

Constants for AdditionalInfo keys

View Source
const (
	ScheduleClassExp = "exp"
)

Constants for scheduling classes

Variables

This section is empty.

Functions

func AddScheduledExpirationNotifications

func AddScheduledExpirationNotifications(rlog log.Ext1FieldLogger, tx *sqlx.Tx, info NotificationInfoBase) error

AddScheduledExpirationNotifications adds all the needed expiration notifications for all the mytokens linked to a Notification

func AddTokenToNotification

func AddTokenToNotification(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, notificationID uint64, mtID mtid.MOMID, includeChildren bool,
) (err error)

AddTokenToNotification subscribes an additional token (and possibly its children) to a notification

func Delete

func Delete(rlog log.Ext1FieldLogger, tx *sqlx.Tx, managementCode string) error

Delete deletes the notification for a managementCode

func DeleteScheduledExpirationNotifications

func DeleteScheduledExpirationNotifications(rlog log.Ext1FieldLogger, tx *sqlx.Tx, nid uint64) error

DeleteScheduledExpirationNotifications deletes all scheduled notifications for a Notification

func DeleteScheduledExpirationNotificationsForMT

func DeleteScheduledExpirationNotificationsForMT(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, nid uint64, mtID mtid.MTID,
) error

DeleteScheduledExpirationNotificationsForMT deletes all scheduled notifications for a Notification and a certain mytoken

func ExpandNotificationsToChildrenIfApplicable

func ExpandNotificationsToChildrenIfApplicable(rlog log.Ext1FieldLogger, tx *sqlx.Tx, parent, child mtid.MTID) error

ExpandNotificationsToChildrenIfApplicable checks if there is a notification subscription for the parent token that should include its children, and if so expands the subscription to also the just created child

func GetNotificationsAndCalendarsForMT

func GetNotificationsAndCalendarsForMT(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, mtID any,
) (notifications []api.NotificationInfo, calendars []api.CalendarInfo, err error)

GetNotificationsAndCalendarsForMT obtains all api.NotificationInfo and api. CalendarInfo for a mytoken from the database

func GetNotificationsForMTAndClass

func GetNotificationsForMTAndClass(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, mtID mtid.MTID,
	class *api.NotificationClass,
) (notifications []api.NotificationInfoBase, err error)

GetNotificationsForMTAndClass checks for and returns the found notifications for a certain mytoken and notification class

func GetNotificationsForUser

func GetNotificationsForUser(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, mtID mtid.MTID,
) (notifications []api.NotificationInfo, err error)

GetNotificationsForUser returns all found notifications for a user

func NewNotification

func NewNotification(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, req pkg.SubscribeNotificationRequest,
	mtID mtid.MOMID, managementCode, ws string,
) error

NewNotification stores a new notification in the database

func RemoveTokenFromNotification

func RemoveTokenFromNotification(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, notificationID uint64, mtID mtid.MOMID,
) (err error)

RemoveTokenFromNotification unsubscribes a token (and possibly its children) from a notification

func ScheduleExpirationNotifications

func ScheduleExpirationNotifications(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, nid uint64, mtID mtid.MTID,
	expiresAt unixtime.UnixTime, createdAt unixtime.UnixTime,
) error

ScheduleExpirationNotifications schedules all the needed expiration notifications for this mytoken

func ScheduleExpirationNotificationsIfNeeded

func ScheduleExpirationNotificationsIfNeeded(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, mtID mtid.MTID, expiresAt unixtime.UnixTime, createdAt unixtime.UnixTime,
) error

ScheduleExpirationNotificationsIfNeeded schedules all the needed expiration notifications if an exp notification is enabled for this mytoken

func UpdateNotificationClasses

func UpdateNotificationClasses(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, notificationID uint64, newClasses api.NotificationClasses,
) (err error)

UpdateNotificationClasses updates the notification classes for a notification

Types

type ManagementCodeNotificationInfoResponse

type ManagementCodeNotificationInfoResponse struct {
	api.ManagementCodeNotificationInfoResponse
	UID uint64 `db:"uid" json:"-"`
}

ManagementCodeNotificationInfoResponse extens api.ManagementCodeNotificationInfoResponse with an uid (not for json)

func GetNotificationForManagementCode

func GetNotificationForManagementCode(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, managementCode string,
) (info *ManagementCodeNotificationInfoResponse, err error)

GetNotificationForManagementCode returns the notification for a management code

type NotificationInfoBase

type NotificationInfoBase struct {
	api.NotificationInfoBase
	WebSocketPath db.NullString `db:"ws" json:"ws,omitempty"`
	UID           uint64        `db:"uid" json:"-"`
}

NotificationInfoBase is a type for holding information about a notification

type NotificationInfoBaseWithClass

type NotificationInfoBaseWithClass struct {
	NotificationInfoBase
	Class string `db:"class"`
}

NotificationInfoBaseWithClass is a type for holding information about a notification including class

func GetNotificationsForMT

func GetNotificationsForMT(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, mtID any,
) (notifications []NotificationInfoBaseWithClass, err error)

GetNotificationsForMT checks for and returns the found notifications for a certain mytoken

type ScheduledNotification

type ScheduledNotification struct {
	ScheduleID     uint64    `db:"id"`
	DueTime        time.Time `db:"due_time"`
	MTID           mtid.MTID `db:"MT_id"`
	Class          string    `db:"class"`
	AdditionalInfo jsonMap   `db:"additional_info"`
	NotificationID uint64    `db:"notification_id"`
	NotificationInfoBase
}

ScheduledNotification holds information about a notification that is scheduled

func PopOneScheduledNotification

func PopOneScheduledNotification(rlog log.Ext1FieldLogger, tx *sqlx.Tx) (*ScheduledNotification, error)

PopOneScheduledNotification pops one ScheduledNotification from the database that is due

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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