✨ Add metadata to post related notification
This commit is contained in:
@ -88,7 +88,7 @@ func ModifyPosterVoteCount(user models.Account, isUpvote bool, delta int) error
|
||||
return database.C.Save(&user).Error
|
||||
}
|
||||
|
||||
func NotifyPosterAccount(user models.Account, title, body string, subtitle *string) error {
|
||||
func NotifyPosterAccount(user models.Account, post models.Post, title, body string, subtitle *string) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
|
||||
@ -99,10 +99,13 @@ func NotifyPosterAccount(user models.Account, title, body string, subtitle *stri
|
||||
_, err = proto.NewNotifierClient(pc).NotifyUser(ctx, &proto.NotifyUserRequest{
|
||||
UserId: uint64(user.ID),
|
||||
Notify: &proto.NotifyRequest{
|
||||
Topic: "interactive.feedback",
|
||||
Title: title,
|
||||
Subtitle: subtitle,
|
||||
Body: body,
|
||||
Topic: "interactive.feedback",
|
||||
Title: title,
|
||||
Subtitle: subtitle,
|
||||
Body: body,
|
||||
Metadata: hyper.EncodeMap(map[string]any{
|
||||
"related_post": post,
|
||||
}),
|
||||
IsRealtime: false,
|
||||
IsForcePush: true,
|
||||
},
|
||||
|
@ -339,6 +339,7 @@ func NewPost(user models.Account, item models.Post) (models.Post, error) {
|
||||
log.Debug().Uint("user", op.AuthorID).Msg("Notifying the original poster their post got replied...")
|
||||
err = NotifyPosterAccount(
|
||||
op.Author,
|
||||
op,
|
||||
"Post got replied",
|
||||
fmt.Sprintf("%s (%s) replied your post (#%d).", user.Nick, user.Name, op.ID),
|
||||
lo.ToPtr(fmt.Sprintf("%s replied you", user.Nick)),
|
||||
@ -421,6 +422,7 @@ func ReactPost(user models.Account, reaction models.Reaction) (bool, models.Reac
|
||||
if op.Author.ID != user.ID {
|
||||
err = NotifyPosterAccount(
|
||||
op.Author,
|
||||
op,
|
||||
"Post got reacted",
|
||||
fmt.Sprintf("%s (%s) reacted your post a %s.", user.Nick, user.Name, reaction.Symbol),
|
||||
lo.ToPtr(fmt.Sprintf("%s reacted you", user.Nick)),
|
||||
|
Reference in New Issue
Block a user