diff --git a/go.mod b/go.mod index 64fce12..c6cace1 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.solsynth.dev/hydrogen/interactive go 1.21.6 require ( - git.solsynth.dev/hydrogen/dealer v0.0.0-20241014131829-4de0c4c969ad + git.solsynth.dev/hydrogen/dealer v0.0.0-20241015165700-60e4bbfd9782 github.com/go-playground/validator/v10 v10.17.0 github.com/gofiber/fiber/v2 v2.52.4 github.com/json-iterator/go v1.1.12 diff --git a/go.sum b/go.sum index f293fad..11e7278 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ git.solsynth.dev/hydrogen/dealer v0.0.0-20240919131945-00c52eba6827 h1:1ACMPm2Ar git.solsynth.dev/hydrogen/dealer v0.0.0-20240919131945-00c52eba6827/go.mod h1:Q51JPkKnV0UoOT/IRmdBh5CyfSlp7s8BRGzgooYHqkI= git.solsynth.dev/hydrogen/dealer v0.0.0-20241014131829-4de0c4c969ad h1:QzK7mg+02jvdfjsXu89KMP3l/QoAMRyWgGDuNzUvTpg= git.solsynth.dev/hydrogen/dealer v0.0.0-20241014131829-4de0c4c969ad/go.mod h1:Q51JPkKnV0UoOT/IRmdBh5CyfSlp7s8BRGzgooYHqkI= +git.solsynth.dev/hydrogen/dealer v0.0.0-20241015165700-60e4bbfd9782 h1:HUgt8RmDp5AKLlT/QGk4QXcO23OEMVpRYRjgLfOf45c= +git.solsynth.dev/hydrogen/dealer v0.0.0-20241015165700-60e4bbfd9782/go.mod h1:Q51JPkKnV0UoOT/IRmdBh5CyfSlp7s8BRGzgooYHqkI= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= diff --git a/pkg/internal/services/accounts.go b/pkg/internal/services/accounts.go index 877a6d5..1973827 100644 --- a/pkg/internal/services/accounts.go +++ b/pkg/internal/services/accounts.go @@ -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, }, diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index 131a370..36f1ef0 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -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)),