Skip to content

Commit

Permalink
Avoid showing npubs, use thread_id, passive interruptions
Browse files Browse the repository at this point in the history
  • Loading branch information
dcadenas committed Aug 27, 2024
1 parent 944d0bc commit ecf94d0
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions service/adapters/apns/apns.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package apns

import (
"encoding/json"
"strings"
"time"

"github.com/boreq/errors"
Expand Down Expand Up @@ -132,17 +133,28 @@ func (a *APNS) buildFollowChangeNotification(followChange domain.FollowChange, a

func followChangePayload(followChange domain.FollowChange) ([]byte, error) {
alertMessage := ""
if followChange.ChangeType == "unfollowed" {
alertMessage = followChange.FriendlyFollower + " has unfollowed you!"
if strings.HasPrefix(followChange.FriendlyFollowee, "npub") {
if followChange.ChangeType == "unfollowed" {
alertMessage = "You've been unfollowed!"
} else {
alertMessage = "You have a new follower!"
}
} else {
alertMessage = followChange.FriendlyFollower + " is a new follower!"
if followChange.ChangeType == "unfollowed" {
alertMessage = followChange.FriendlyFollower + " has unfollowed you!"
} else {
alertMessage = followChange.FriendlyFollower + " is a new follower!"
}
}

// See https://developer.apple.com/documentation/usernotifications/generating-a-remote-notification
payload := map[string]interface{}{
"aps": map[string]interface{}{
"alert": alertMessage,
"sound": "default",
"badge": 1,
"alert": alertMessage,
"sound": "default",
"badge": 1,
"thread-id": followChange.Followee.Hex(),
"interruption-level": "passive",
},
"data": map[string]interface{}{
"changeType": followChange.ChangeType,
Expand Down

0 comments on commit ecf94d0

Please sign in to comment.