Skip to content

Commit f751569

Browse files
committed
chat/v2: add chat_id to push header, debug logs
1 parent e78b028 commit f751569

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pkg/code/push/notifications.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/code-payments/code-server/pkg/code/common"
1717
code_data "github.com/code-payments/code-server/pkg/code/data"
1818
chat_v1 "github.com/code-payments/code-server/pkg/code/data/chat/v1"
19+
chat_v2 "github.com/code-payments/code-server/pkg/code/data/chat/v2"
1920
"github.com/code-payments/code-server/pkg/code/localization"
2021
"github.com/code-payments/code-server/pkg/code/thirdparty"
2122
currency_lib "github.com/code-payments/code-server/pkg/currency"
@@ -418,6 +419,7 @@ func SendChatMessagePushNotificationV2(
418419
ctx context.Context,
419420
data code_data.Provider,
420421
pusher push_lib.Provider,
422+
chatId chat_v2.ChatId,
421423
chatTitle string,
422424
owner *common.Account,
423425
chatMessage *chatv2pb.ChatMessage,
@@ -533,6 +535,7 @@ func SendChatMessagePushNotificationV2(
533535

534536
kvs := map[string]string{
535537
"chat_title": localizedPushTitle,
538+
"chat_id": chatId.String(),
536539
"message_content": base64.StdEncoding.EncodeToString(marshalledContent),
537540
}
538541

pkg/code/server/grpc/chat/v2/server.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,10 +1412,11 @@ func (s *Server) onPersistChatMessage(log *logrus.Entry, chatId chat.ChatId, cha
14121412
func (s *Server) sendPushNotifications(chatId chat.ChatId, chatTitle string, sender chat.MemberId, message *chatpb.ChatMessage) {
14131413
log := s.log.WithFields(logrus.Fields{
14141414
"method": "sendPushNotifications",
1415+
"sender": sender.String(),
14151416
"chat_id": chatId.String(),
14161417
})
14171418

1418-
// todo: err group
1419+
// TODO: Callers might already have this loaded.
14191420
members, err := s.data.GetAllChatMembersV2(context.Background(), chatId)
14201421
if err != nil {
14211422
log.WithError(err).Warn("failure getting chat members")
@@ -1438,10 +1439,12 @@ func (s *Server) sendPushNotifications(chatId chat.ChatId, chatTitle string, sen
14381439

14391440
m := m
14401441
eg.Go(func() error {
1442+
log.WithField("member", m.MemberId.String()).Info("sending push notification")
14411443
err = push_util.SendChatMessagePushNotificationV2(
14421444
context.Background(),
14431445
s.data,
14441446
s.push,
1447+
chatId,
14451448
chatTitle,
14461449
owner,
14471450
message,

0 commit comments

Comments
 (0)