feat(notifications): add actor_handle and navigation targets for deep linking
This commit is contained in:
parent
80d7d92ebd
commit
23bf5a15b4
|
|
@ -112,6 +112,7 @@ type PushNotificationRequest struct {
|
||||||
ActorID uuid.UUID
|
ActorID uuid.UUID
|
||||||
ActorName string
|
ActorName string
|
||||||
ActorAvatar string
|
ActorAvatar string
|
||||||
|
ActorHandle string
|
||||||
PostID *uuid.UUID
|
PostID *uuid.UUID
|
||||||
CommentID *uuid.UUID
|
CommentID *uuid.UUID
|
||||||
PostType string // "standard", "quip", "beacon"
|
PostType string // "standard", "quip", "beacon"
|
||||||
|
|
|
||||||
|
|
@ -222,6 +222,9 @@ func (s *NotificationService) sendNotification(ctx context.Context, req models.P
|
||||||
if actor.AvatarURL != nil {
|
if actor.AvatarURL != nil {
|
||||||
req.ActorAvatar = *actor.AvatarURL
|
req.ActorAvatar = *actor.AvatarURL
|
||||||
}
|
}
|
||||||
|
if actor.Handle != nil {
|
||||||
|
req.ActorHandle = *actor.Handle
|
||||||
|
}
|
||||||
|
|
||||||
// Create in-app notification record
|
// Create in-app notification record
|
||||||
notif := &models.Notification{
|
notif := &models.Notification{
|
||||||
|
|
@ -300,6 +303,9 @@ func (s *NotificationService) buildPushPayload(req models.PushNotificationReques
|
||||||
if req.CommentID != nil {
|
if req.CommentID != nil {
|
||||||
data["comment_id"] = req.CommentID.String()
|
data["comment_id"] = req.CommentID.String()
|
||||||
}
|
}
|
||||||
|
if req.ActorHandle != "" {
|
||||||
|
data["actor_handle"] = req.ActorHandle
|
||||||
|
}
|
||||||
if req.PostType != "" {
|
if req.PostType != "" {
|
||||||
data["post_type"] = req.PostType
|
data["post_type"] = req.PostType
|
||||||
}
|
}
|
||||||
|
|
@ -335,12 +341,20 @@ func (s *NotificationService) buildPushPayload(req models.PushNotificationReques
|
||||||
case models.NotificationTypeFollow:
|
case models.NotificationTypeFollow:
|
||||||
title = "New Follower"
|
title = "New Follower"
|
||||||
body = fmt.Sprintf("%s started following you", actorName)
|
body = fmt.Sprintf("%s started following you", actorName)
|
||||||
data["follower_id"] = req.ActorID.String()
|
if req.ActorHandle != "" {
|
||||||
|
data["follower_id"] = req.ActorHandle
|
||||||
|
} else {
|
||||||
|
data["follower_id"] = req.ActorID.String()
|
||||||
|
}
|
||||||
|
|
||||||
case models.NotificationTypeFollowRequest:
|
case models.NotificationTypeFollowRequest:
|
||||||
title = "Follow Request"
|
title = "Follow Request"
|
||||||
body = fmt.Sprintf("%s wants to follow you", actorName)
|
body = fmt.Sprintf("%s wants to follow you", actorName)
|
||||||
data["follower_id"] = req.ActorID.String()
|
if req.ActorHandle != "" {
|
||||||
|
data["follower_id"] = req.ActorHandle
|
||||||
|
} else {
|
||||||
|
data["follower_id"] = req.ActorID.String()
|
||||||
|
}
|
||||||
|
|
||||||
case models.NotificationTypeFollowAccept:
|
case models.NotificationTypeFollowAccept:
|
||||||
title = "Request Accepted"
|
title = "Request Accepted"
|
||||||
|
|
@ -364,6 +378,10 @@ func (s *NotificationService) buildPushPayload(req models.PushNotificationReques
|
||||||
body = fmt.Sprintf("%s reported your beacon", actorName)
|
body = fmt.Sprintf("%s reported your beacon", actorName)
|
||||||
data["beacon_id"] = req.PostID.String()
|
data["beacon_id"] = req.PostID.String()
|
||||||
|
|
||||||
|
case models.NotificationTypeQuipReaction:
|
||||||
|
title = "New Reaction"
|
||||||
|
body = fmt.Sprintf("%s reacted to your quip", actorName)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
title = "Sojorn"
|
title = "Sojorn"
|
||||||
body = "You have a new notification"
|
body = "You have a new notification"
|
||||||
|
|
@ -380,6 +398,8 @@ func (s *NotificationService) getNavigationTarget(notifType, postType string) st
|
||||||
return "profile"
|
return "profile"
|
||||||
case models.NotificationTypeBeaconVouch, models.NotificationTypeBeaconReport:
|
case models.NotificationTypeBeaconVouch, models.NotificationTypeBeaconReport:
|
||||||
return "beacon_map"
|
return "beacon_map"
|
||||||
|
case models.NotificationTypeQuipReaction:
|
||||||
|
return "quip_feed"
|
||||||
default:
|
default:
|
||||||
switch postType {
|
switch postType {
|
||||||
case "beacon":
|
case "beacon":
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue