1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-01-08 15:06:08 +02:00
focalboard/server/model/notification.go
Rajat Dabade c8e729b6fe
[Refactor]: updated dependency for focalboard server (#5009)
* refactor: updated dependency for focalboard server

* chore: more dependency fixes

* refactor: removed the unless code

* refactor: added ctx for login and removed unnessary code

* refactor: bump up go version

* refactor: removed the commented code

* chore: upgraded golinter version

* fix: linter issue

* refactor: removed feature flg fix golinter

* refactor: removed feature flag from code

* revert: statistic and it's function

* refactor: removed ProductLimit related code

* refactor: removed isWithinViewsLimit implementation

* refactor: moved function GetUsedCardsCount to statistics.go from cloud.go

* refactor: removed insight code board

* refactor: removed limit dialog

* refactor: updated dependencies for linux

* chore: golinter fix

* chore: updated helper test function to use newLogger

* fix: go test

* refactor: db ping attempts from config

* revert: feature in action

* revert: feature flag in action

* revert: boardsEditor setting

---------

Co-authored-by: Rajat Dabade <rajat@Rajats-MacBook-Pro.local>
2024-06-07 23:30:08 +05:30

82 lines
2.2 KiB
Go

package model
import (
"time"
"github.com/mattermost/mattermost/server/v8/channels/utils"
)
// NotificationHint provides a hint that a block has been modified and has subscribers that
// should be notified.
// swagger:model
type NotificationHint struct {
// BlockType is the block type of the entity (e.g. board, card) that was updated
// required: true
BlockType BlockType `json:"block_type"`
// BlockID is id of the entity that was updated
// required: true
BlockID string `json:"block_id"`
// ModifiedByID is the id of the user who made the block change
ModifiedByID string `json:"modified_by_id"`
// CreatedAt is the timestamp this notification hint was created in miliseconds since the current epoch
// required: true
CreateAt int64 `json:"create_at"`
// NotifyAt is the timestamp this notification should be scheduled in miliseconds since the current epoch
// required: true
NotifyAt int64 `json:"notify_at"`
}
func (s *NotificationHint) IsValid() error {
if s == nil {
return ErrInvalidNotificationHint{"cannot be nil"}
}
if s.BlockID == "" {
return ErrInvalidNotificationHint{"missing block id"}
}
if s.BlockType == "" {
return ErrInvalidNotificationHint{"missing block type"}
}
if s.ModifiedByID == "" {
return ErrInvalidNotificationHint{"missing modified_by id"}
}
return nil
}
func (s *NotificationHint) Copy() *NotificationHint {
return &NotificationHint{
BlockType: s.BlockType,
BlockID: s.BlockID,
ModifiedByID: s.ModifiedByID,
CreateAt: s.CreateAt,
NotifyAt: s.NotifyAt,
}
}
func (s *NotificationHint) LogClone() interface{} {
return struct {
BlockType BlockType `json:"block_type"`
BlockID string `json:"block_id"`
ModifiedByID string `json:"modified_by_id"`
CreateAt string `json:"create_at"`
NotifyAt string `json:"notify_at"`
}{
BlockType: s.BlockType,
BlockID: s.BlockID,
ModifiedByID: s.ModifiedByID,
CreateAt: utils.TimeFromMillis(s.CreateAt).Format(time.StampMilli),
NotifyAt: utils.TimeFromMillis(s.NotifyAt).Format(time.StampMilli),
}
}
type ErrInvalidNotificationHint struct {
msg string
}
func (e ErrInvalidNotificationHint) Error() string {
return e.msg
}