This PR adds the post reminder backend work.

We add a new API endpoint via which a user can set a reminder for a post. An ephemeral message will be sent down the line to let the user know about the action. And then after the time is over, the system admin bot will send a DM message to the user about the reminder post.
Этот коммит содержится в:
Agniva De Sarker
2022-07-26 16:12:56 +05:30
коммит произвёл GitHub
родитель e6459b97de
Коммит 20cb042362
23 изменённых файлов: 849 добавлений и 16 удалений

Просмотреть файл

@@ -5258,6 +5258,38 @@ func (s *TimerLayerPostStore) GetPostIdBeforeTime(channelID string, timestamp in
return result, err
}
func (s *TimerLayerPostStore) GetPostReminderMetadata(postID string) (*store.PostReminderMetadata, error) {
start := time.Now()
result, err := s.PostStore.GetPostReminderMetadata(postID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostReminderMetadata", success, elapsed)
}
return result, err
}
func (s *TimerLayerPostStore) GetPostReminders(now int64) ([]*model.PostReminder, error) {
start := time.Now()
result, err := s.PostStore.GetPostReminders(now)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.GetPostReminders", success, elapsed)
}
return result, err
}
func (s *TimerLayerPostStore) GetPosts(options model.GetPostsOptions, allowFromCache bool, sanitizeOptions map[string]bool) (*model.PostList, error) {
start := time.Now()
@@ -5641,6 +5673,22 @@ func (s *TimerLayerPostStore) SearchPostsForUser(paramsList []*model.SearchParam
return result, err
}
func (s *TimerLayerPostStore) SetPostReminder(reminder *model.PostReminder) error {
start := time.Now()
err := s.PostStore.SetPostReminder(reminder)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("PostStore.SetPostReminder", success, elapsed)
}
return err
}
func (s *TimerLayerPostStore) Update(newPost *model.Post, oldPost *model.Post) (*model.Post, error) {
start := time.Now()