notifications

package
v1.48.4 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cursor added in v0.29.0

type Cursor struct {
	Limit uint
	Page  uint
}

Cursor holds notification cursor entity which is used to create listed page from database.

type DB

type DB interface {
	Insert(ctx context.Context, notification NewNotification) (Notification, error)
	List(ctx context.Context, cursor Cursor) (Page, error)
	Read(ctx context.Context, notificationID uuid.UUID) error
	ReadAll(ctx context.Context) error
	UnreadAmount(ctx context.Context) (int, error)
}

DB tells how application works with notifications database.

architecture: Database

type NewNotification

type NewNotification struct {
	SenderID storj.NodeID
	Type     Type
	Title    string
	Message  string
}

NewNotification holds notification entity info which is being received from satellite or local client.

type Notification

type Notification struct {
	ID        uuid.UUID    `json:"id"`
	SenderID  storj.NodeID `json:"senderId"`
	Type      Type         `json:"type"`
	Title     string       `json:"title"`
	Message   string       `json:"message"`
	ReadAt    *time.Time   `json:"readAt"`
	CreatedAt time.Time    `json:"createdAt"`
}

Notification holds notification entity info which is being retrieved from database.

type Page added in v0.29.0

type Page struct {
	Notifications []Notification `json:"notifications"`

	Offset      uint64 `json:"offset"`
	Limit       uint   `json:"limit"`
	CurrentPage uint   `json:"currentPage"`
	PageCount   uint   `json:"pageCount"`
	TotalCount  uint64 `json:"totalCount"`
}

Page holds notification page entity which is used to show listed page of notifications on UI.

type Service added in v0.29.0

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

Service is the notification service between storage nodes and satellites. architecture: Service

func NewService added in v0.29.0

func NewService(log *zap.Logger, db DB) *Service

NewService creates a new notification service.

func (*Service) List added in v0.29.0

func (service *Service) List(ctx context.Context, cursor Cursor) (_ Page, err error)

List - shows the list of paginated notifications.

func (*Service) Read added in v0.29.0

func (service *Service) Read(ctx context.Context, notificationID uuid.UUID) (err error)

Read - change notification status to Read by ID.

func (*Service) ReadAll added in v0.29.0

func (service *Service) ReadAll(ctx context.Context) (err error)

ReadAll - change status of all user's notifications to Read.

func (*Service) Receive added in v0.29.0

func (service *Service) Receive(ctx context.Context, newNotification NewNotification) (Notification, error)

Receive - receives notifications from satellite and Insert them into DB.

func (*Service) UnreadAmount added in v0.30.0

func (service *Service) UnreadAmount(ctx context.Context) (_ int, err error)

UnreadAmount - returns amount on notifications with value is_read = nil.

type TimesNotified added in v1.8.1

type TimesNotified int

TimesNotified is a numeric value of amount of notifications being sent to user.

const (
	// TimesNotifiedZero haven't being notified yet.
	TimesNotifiedZero TimesNotified = 0
	// TimesNotifiedFirst sent notification one time.
	TimesNotifiedFirst TimesNotified = 1
	// TimesNotifiedSecond sent notifications twice.
	TimesNotifiedSecond TimesNotified = 2
	// TimesNotifiedLast three notification has been send.
	TimesNotifiedLast TimesNotified = 3
)

type Type added in v0.29.0

type Type int

Type is a numeric value of specific notification type.

const (
	// TypeCustom is a common notification type which doesn't describe node's core functionality.
	// TODO: change type name when all notification types will be known.
	TypeCustom Type = 0
	// TypeAuditCheckFailure is a notification type which describes node's audit check failure.
	TypeAuditCheckFailure Type = 1
	// TypeDisqualification is a notification type which describes node's disqualification status.
	TypeDisqualification Type = 2
	// TypeSuspension is a notification type which describes node's suspension status.
	TypeSuspension Type = 3
)

Jump to

Keyboard shortcuts

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