🐛 Fix the notify type

This commit is contained in:
LittleSheep 2024-06-08 16:34:14 +08:00
parent e129575eff
commit 9b76311462
3 changed files with 7 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package services
import (
"context"
"fmt"
"git.solsynth.dev/hydrogen/messaging/pkg/database"
"time"
@ -31,16 +32,16 @@ func GetAccountFriend(userId, relatedId uint, status int) (*proto.FriendshipResp
})
}
func NotifyAccountMessager(user models.Account, subject, content string, realtime bool, forcePush bool, links ...*proto.NotifyLink) error {
func NotifyAccountMessager(user models.Account, t, s, c string, realtime bool, forcePush bool, links ...*proto.NotifyLink) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
_, err := grpc.Notify.NotifyUser(ctx, &proto.NotifyRequest{
ClientId: viper.GetString("passport.client_id"),
ClientSecret: viper.GetString("passport.client_secret"),
Type: "notifications.messaging",
Subject: subject,
Content: content,
Type: fmt.Sprintf("messaging.%s", t),
Subject: s,
Content: c,
Links: links,
RecipientId: uint64(user.ExternalID),
IsRealtime: realtime,

View File

@ -100,6 +100,7 @@ func NewCall(channel models.Channel, founder models.ChannelMember) (models.Call,
for _, member := range members {
if member.ID != call.Founder.ID {
err = NotifyAccountMessager(member.Account,
"incomingCall",
fmt.Sprintf("Call in #%s", channel.Alias),
fmt.Sprintf("%s started a new call", call.Founder.Account.Name),
false,

View File

@ -117,6 +117,7 @@ func NewMessage(message models.Message) (models.Message, error) {
}
err = NotifyAccountMessager(member.Account,
"incomingMessage",
fmt.Sprintf("%s in #%s", message.Sender.Account.Nick, channel.Alias),
fmt.Sprintf("%s", displayText),
true,