🐛 Fix the notify type
This commit is contained in:
		@@ -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,
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user