[MM-47751][MM-48102] MPA: Send Persistent Notifications (#21619)
* MM-46410: adds urgency on mention counts We have introduced priority for posts in https://github.com/mattermost/mattermost-webapp/pull/10951. We do need to color the mention badges in the webapp with a prominent color when a mention is posted in an urgent message. A thread has urgent mentions if the root post is marked as urgent, and the replies contain mentions to the user viewing the thread. This PR adds two columns, urgentmentioncount, and isurgent, in channelmembers, and threads tables respectively. Furthermore when asking for team/thread mention counts, we also return urgent mention counts for the user. * Adds PostAcknowledgements table and apis * job init and fetch mentions * add-migrations * delete-expired * send-notifications * Fetches post priority in batches * stop-notifications * stop-notification-on-reply * MM-47750: Adds PostAcknowledgements table and apis - Adds post acknowledgement api/app/store methods to be able to save and delete post acknowledgements by users. - Adds wesbsocket events for acknowledgement created/deleted - Returns post acknowledgements in the post's metadata * add-license-check * add-pagination * delete on channel and team * validate guests * add configs * move create priority post check from app to api * Add desktop notifications * check status * use config in job * add IsUrgent check * Add last-sent-at * validate max recipients * Update lastSentAt * Validate min. recipient * send email notification only once * remove email notifications * use latest time from config to run job * Add notifications counter * publish events to mentioned users only * pickup license updates in scheduler * don't allow post owner to stop notifications * follow normal notifications behaviour * Validates persistent notifications interval * move logic of handling valid and expired posts into sql * Adds persistent notifications in the webapp --------- Co-authored-by: koox00 <3829551+koox00@users.noreply.github.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -22,48 +22,49 @@ const mySQLDeadlockCode = uint16(1213)
|
||||
|
||||
type RetryLayer struct {
|
||||
store.Store
|
||||
AuditStore store.AuditStore
|
||||
BotStore store.BotStore
|
||||
ChannelStore store.ChannelStore
|
||||
ChannelMemberHistoryStore store.ChannelMemberHistoryStore
|
||||
ClusterDiscoveryStore store.ClusterDiscoveryStore
|
||||
CommandStore store.CommandStore
|
||||
CommandWebhookStore store.CommandWebhookStore
|
||||
ComplianceStore store.ComplianceStore
|
||||
DraftStore store.DraftStore
|
||||
EmojiStore store.EmojiStore
|
||||
FileInfoStore store.FileInfoStore
|
||||
GroupStore store.GroupStore
|
||||
JobStore store.JobStore
|
||||
LicenseStore store.LicenseStore
|
||||
LinkMetadataStore store.LinkMetadataStore
|
||||
NotifyAdminStore store.NotifyAdminStore
|
||||
OAuthStore store.OAuthStore
|
||||
PluginStore store.PluginStore
|
||||
PostStore store.PostStore
|
||||
PostAcknowledgementStore store.PostAcknowledgementStore
|
||||
PostPriorityStore store.PostPriorityStore
|
||||
PreferenceStore store.PreferenceStore
|
||||
ProductNoticesStore store.ProductNoticesStore
|
||||
ReactionStore store.ReactionStore
|
||||
RemoteClusterStore store.RemoteClusterStore
|
||||
RetentionPolicyStore store.RetentionPolicyStore
|
||||
RoleStore store.RoleStore
|
||||
SchemeStore store.SchemeStore
|
||||
SessionStore store.SessionStore
|
||||
SharedChannelStore store.SharedChannelStore
|
||||
StatusStore store.StatusStore
|
||||
SystemStore store.SystemStore
|
||||
TeamStore store.TeamStore
|
||||
TermsOfServiceStore store.TermsOfServiceStore
|
||||
ThreadStore store.ThreadStore
|
||||
TokenStore store.TokenStore
|
||||
TrueUpReviewStore store.TrueUpReviewStore
|
||||
UploadSessionStore store.UploadSessionStore
|
||||
UserStore store.UserStore
|
||||
UserAccessTokenStore store.UserAccessTokenStore
|
||||
UserTermsOfServiceStore store.UserTermsOfServiceStore
|
||||
WebhookStore store.WebhookStore
|
||||
AuditStore store.AuditStore
|
||||
BotStore store.BotStore
|
||||
ChannelStore store.ChannelStore
|
||||
ChannelMemberHistoryStore store.ChannelMemberHistoryStore
|
||||
ClusterDiscoveryStore store.ClusterDiscoveryStore
|
||||
CommandStore store.CommandStore
|
||||
CommandWebhookStore store.CommandWebhookStore
|
||||
ComplianceStore store.ComplianceStore
|
||||
DraftStore store.DraftStore
|
||||
EmojiStore store.EmojiStore
|
||||
FileInfoStore store.FileInfoStore
|
||||
GroupStore store.GroupStore
|
||||
JobStore store.JobStore
|
||||
LicenseStore store.LicenseStore
|
||||
LinkMetadataStore store.LinkMetadataStore
|
||||
NotifyAdminStore store.NotifyAdminStore
|
||||
OAuthStore store.OAuthStore
|
||||
PluginStore store.PluginStore
|
||||
PostStore store.PostStore
|
||||
PostAcknowledgementStore store.PostAcknowledgementStore
|
||||
PostPersistentNotificationStore store.PostPersistentNotificationStore
|
||||
PostPriorityStore store.PostPriorityStore
|
||||
PreferenceStore store.PreferenceStore
|
||||
ProductNoticesStore store.ProductNoticesStore
|
||||
ReactionStore store.ReactionStore
|
||||
RemoteClusterStore store.RemoteClusterStore
|
||||
RetentionPolicyStore store.RetentionPolicyStore
|
||||
RoleStore store.RoleStore
|
||||
SchemeStore store.SchemeStore
|
||||
SessionStore store.SessionStore
|
||||
SharedChannelStore store.SharedChannelStore
|
||||
StatusStore store.StatusStore
|
||||
SystemStore store.SystemStore
|
||||
TeamStore store.TeamStore
|
||||
TermsOfServiceStore store.TermsOfServiceStore
|
||||
ThreadStore store.ThreadStore
|
||||
TokenStore store.TokenStore
|
||||
TrueUpReviewStore store.TrueUpReviewStore
|
||||
UploadSessionStore store.UploadSessionStore
|
||||
UserStore store.UserStore
|
||||
UserAccessTokenStore store.UserAccessTokenStore
|
||||
UserTermsOfServiceStore store.UserTermsOfServiceStore
|
||||
WebhookStore store.WebhookStore
|
||||
}
|
||||
|
||||
func (s *RetryLayer) Audit() store.AuditStore {
|
||||
@@ -146,6 +147,10 @@ func (s *RetryLayer) PostAcknowledgement() store.PostAcknowledgementStore {
|
||||
return s.PostAcknowledgementStore
|
||||
}
|
||||
|
||||
func (s *RetryLayer) PostPersistentNotification() store.PostPersistentNotificationStore {
|
||||
return s.PostPersistentNotificationStore
|
||||
}
|
||||
|
||||
func (s *RetryLayer) PostPriority() store.PostPriorityStore {
|
||||
return s.PostPriorityStore
|
||||
}
|
||||
@@ -334,6 +339,11 @@ type RetryLayerPostAcknowledgementStore struct {
|
||||
Root *RetryLayer
|
||||
}
|
||||
|
||||
type RetryLayerPostPersistentNotificationStore struct {
|
||||
store.PostPersistentNotificationStore
|
||||
Root *RetryLayer
|
||||
}
|
||||
|
||||
type RetryLayerPostPriorityStore struct {
|
||||
store.PostPriorityStore
|
||||
Root *RetryLayer
|
||||
@@ -7750,6 +7760,153 @@ func (s *RetryLayerPostAcknowledgementStore) Save(postID string, userID string,
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostPersistentNotificationStore) Delete(postIds []string) error {
|
||||
|
||||
tries := 0
|
||||
for {
|
||||
err := s.PostPersistentNotificationStore.Delete(postIds)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return err
|
||||
}
|
||||
timepkg.Sleep(100 * timepkg.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostPersistentNotificationStore) DeleteByChannel(channelIds []string) error {
|
||||
|
||||
tries := 0
|
||||
for {
|
||||
err := s.PostPersistentNotificationStore.DeleteByChannel(channelIds)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return err
|
||||
}
|
||||
timepkg.Sleep(100 * timepkg.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostPersistentNotificationStore) DeleteByTeam(teamIds []string) error {
|
||||
|
||||
tries := 0
|
||||
for {
|
||||
err := s.PostPersistentNotificationStore.DeleteByTeam(teamIds)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return err
|
||||
}
|
||||
timepkg.Sleep(100 * timepkg.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostPersistentNotificationStore) DeleteExpired(maxSentCount int16) error {
|
||||
|
||||
tries := 0
|
||||
for {
|
||||
err := s.PostPersistentNotificationStore.DeleteExpired(maxSentCount)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return err
|
||||
}
|
||||
timepkg.Sleep(100 * timepkg.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostPersistentNotificationStore) Get(params model.GetPersistentNotificationsPostsParams) ([]*model.PostPersistentNotifications, error) {
|
||||
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostPersistentNotificationStore.Get(params)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
timepkg.Sleep(100 * timepkg.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostPersistentNotificationStore) GetSingle(postID string) (*model.PostPersistentNotifications, error) {
|
||||
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.PostPersistentNotificationStore.GetSingle(postID)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
timepkg.Sleep(100 * timepkg.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostPersistentNotificationStore) UpdateLastActivity(postIds []string) error {
|
||||
|
||||
tries := 0
|
||||
for {
|
||||
err := s.PostPersistentNotificationStore.UpdateLastActivity(postIds)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return err
|
||||
}
|
||||
timepkg.Sleep(100 * timepkg.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerPostPriorityStore) GetForPost(postId string) (*model.PostPriority, error) {
|
||||
|
||||
tries := 0
|
||||
@@ -14750,6 +14907,7 @@ func New(childStore store.Store) *RetryLayer {
|
||||
newStore.PluginStore = &RetryLayerPluginStore{PluginStore: childStore.Plugin(), Root: &newStore}
|
||||
newStore.PostStore = &RetryLayerPostStore{PostStore: childStore.Post(), Root: &newStore}
|
||||
newStore.PostAcknowledgementStore = &RetryLayerPostAcknowledgementStore{PostAcknowledgementStore: childStore.PostAcknowledgement(), Root: &newStore}
|
||||
newStore.PostPersistentNotificationStore = &RetryLayerPostPersistentNotificationStore{PostPersistentNotificationStore: childStore.PostPersistentNotification(), Root: &newStore}
|
||||
newStore.PostPriorityStore = &RetryLayerPostPriorityStore{PostPriorityStore: childStore.PostPriority(), Root: &newStore}
|
||||
newStore.PreferenceStore = &RetryLayerPreferenceStore{PreferenceStore: childStore.Preference(), Root: &newStore}
|
||||
newStore.ProductNoticesStore = &RetryLayerProductNoticesStore{ProductNoticesStore: childStore.ProductNotices(), Root: &newStore}
|
||||
|
||||
@@ -57,6 +57,7 @@ func genStore() *mocks.Store {
|
||||
mock.On("Draft").Return(&mocks.DraftStore{})
|
||||
mock.On("PostPriority").Return(&mocks.PostPriorityStore{})
|
||||
mock.On("PostAcknowledgement").Return(&mocks.PostAcknowledgementStore{})
|
||||
mock.On("PostPersistentNotification").Return(&mocks.PostPersistentNotificationStore{})
|
||||
mock.On("TrueUpReview").Return(&mocks.TrueUpReviewStore{})
|
||||
return mock
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user