mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-13 07:27:43 +00:00
add most of the missing fields
This commit is contained in:
parent
65f671c96c
commit
fad7191035
2 changed files with 18 additions and 15 deletions
|
@ -370,7 +370,7 @@ func (c *Consumer) Consume(delivery rmq.Delivery) {
|
|||
for _, msg := range msgs.MessageListing.Messages {
|
||||
notification := &apns2.Notification{}
|
||||
notification.Topic = "com.christianselig.Apollo"
|
||||
notification.Payload = payloadFromMessage(&msg)
|
||||
notification.Payload = payloadFromMessage(account, &msg, len(msgs.MessageListing.Messages))
|
||||
|
||||
for _, device := range devices {
|
||||
notification.DeviceToken = device.APNSToken
|
||||
|
@ -404,7 +404,7 @@ func (c *Consumer) Consume(delivery rmq.Delivery) {
|
|||
}).Debug("finishing job")
|
||||
}
|
||||
|
||||
func payloadFromMessage(msg *reddit.MessageData) *payload.Payload {
|
||||
func payloadFromMessage(acct *data.Account, msg *reddit.MessageData, badgeCount int) *payload.Payload {
|
||||
postBody := msg.Body
|
||||
if len(postBody) > 2000 {
|
||||
postBody = msg.Body[:2000]
|
||||
|
@ -418,7 +418,7 @@ func payloadFromMessage(msg *reddit.MessageData) *payload.Payload {
|
|||
postTitle = fmt.Sprintf("%s…", postTitle[0:75])
|
||||
}
|
||||
|
||||
payload := payload.NewPayload().Sound("traloop.wav").AlertBody(postBody).Custom("author", msg.Author).Custom("parent_id", msg.ParentID).AlertSummaryArg(msg.Author).MutableContent()
|
||||
payload := payload.NewPayload().Sound("traloop.wav").AlertBody(postBody).Custom("author", msg.Author).Custom("parent_id", msg.ParentID).AlertSummaryArg(msg.Author).MutableContent().Badge(badgeCount).Custom("post_title", msg.LinkTitle).Custom("destination_author", msg.Destination).Custom("subreddit", msg.Subreddit)
|
||||
|
||||
switch {
|
||||
case (msg.Kind == "t1" && msg.Type == "username_mention"):
|
||||
|
@ -436,11 +436,12 @@ func payloadFromMessage(msg *reddit.MessageData) *payload.Payload {
|
|||
break
|
||||
case (msg.Kind == "t1" && msg.Type == "post_reply"):
|
||||
title := fmt.Sprintf(`%s to “%s”`, msg.Author, postTitle)
|
||||
payload = payload.AlertTitle(title).Custom("type", "post").Category("inbox-post-reply").Custom("subject", "comment").ThreadID("comment")
|
||||
payload = payload.AlertTitle(title).Custom("type", "post").Category("inbox-post-reply").Custom("subject", "comment").ThreadID("comment").Custom("post_id", msg.ID)
|
||||
break
|
||||
case (msg.Kind == "t1" && msg.Type == "comment_reply"):
|
||||
title := fmt.Sprintf(`%s in “%s”`, msg.Author, postTitle)
|
||||
payload = payload.AlertTitle(title).Custom("type", "comment").Category("inbox-comment-reply").Custom("subject", "comment").ThreadID("comment")
|
||||
_, postID := reddit.SplitID(msg.ParentID)
|
||||
payload = payload.AlertTitle(title).Custom("type", "comment").Category("inbox-comment-reply").Custom("subject", "comment").ThreadID("comment").Custom("post_id", postID).Custom("comment_id", msg.ID)
|
||||
break
|
||||
case (msg.Kind == "t4"):
|
||||
title := fmt.Sprintf(`Message from %s`, msg.Author)
|
||||
|
|
|
@ -3,16 +3,18 @@ package reddit
|
|||
import "fmt"
|
||||
|
||||
type Message struct {
|
||||
ID string `json:"id"`
|
||||
Kind string `json:"kind"`
|
||||
Type string `json:"type"`
|
||||
Author string `json:"author"`
|
||||
Subject string `json:"subject"`
|
||||
Body string `json:"body"`
|
||||
CreatedAt float64 `json:"created_utc"`
|
||||
Context string `json:"context"`
|
||||
ParentID string `json:"parent_id"`
|
||||
LinkTitle string `json:"link_title"`
|
||||
ID string `json:"id"`
|
||||
Kind string `json:"kind"`
|
||||
Type string `json:"type"`
|
||||
Author string `json:"author"`
|
||||
Subject string `json:"subject"`
|
||||
Body string `json:"body"`
|
||||
CreatedAt float64 `json:"created_utc"`
|
||||
Context string `json:"context"`
|
||||
ParentID string `json:"parent_id"`
|
||||
LinkTitle string `json:"link_title"`
|
||||
Destination string `json:"dest"`
|
||||
Subreddit string `json:"subreddit"`
|
||||
}
|
||||
|
||||
type MessageData struct {
|
||||
|
|
Loading…
Reference in a new issue