mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-25 13:17:42 +00:00
Change Subreddit watcher notification
This commit is contained in:
parent
f7cbaad454
commit
2027760e1e
1 changed files with 7 additions and 5 deletions
|
@ -40,7 +40,10 @@ type subredditsWorker struct {
|
||||||
watcherRepo domain.WatcherRepository
|
watcherRepo domain.WatcherRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
const subredditNotificationTitleFormat = "📣 %s"
|
const (
|
||||||
|
subredditNotificationTitleFormat = "📣 \u201c%s\u201d Watcher"
|
||||||
|
subredditNotificationBodyFormat = "r/%s: \u201c%s\u201d"
|
||||||
|
)
|
||||||
|
|
||||||
func NewSubredditsWorker(logger *logrus.Logger, statsd *statsd.Client, db *pgxpool.Pool, redis *redis.Client, queue rmq.Connection, consumers int) Worker {
|
func NewSubredditsWorker(logger *logrus.Logger, statsd *statsd.Client, db *pgxpool.Pool, redis *redis.Client, queue rmq.Connection, consumers int) Worker {
|
||||||
reddit := reddit.NewClient(
|
reddit := reddit.NewClient(
|
||||||
|
@ -391,6 +394,9 @@ func (sc *subredditsConsumer) Consume(delivery rmq.Delivery) {
|
||||||
title := fmt.Sprintf(subredditNotificationTitleFormat, watcher.Label)
|
title := fmt.Sprintf(subredditNotificationTitleFormat, watcher.Label)
|
||||||
payload.AlertTitle(title)
|
payload.AlertTitle(title)
|
||||||
|
|
||||||
|
body := fmt.Sprintf(subredditNotificationBodyFormat, subreddit.Name, post.Title)
|
||||||
|
payload.AlertBody(body)
|
||||||
|
|
||||||
notification := &apns2.Notification{}
|
notification := &apns2.Notification{}
|
||||||
notification.Topic = "com.christianselig.Apollo"
|
notification.Topic = "com.christianselig.Apollo"
|
||||||
notification.DeviceToken = watcher.Device.APNSToken
|
notification.DeviceToken = watcher.Device.APNSToken
|
||||||
|
@ -429,12 +435,8 @@ func (sc *subredditsConsumer) Consume(delivery rmq.Delivery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func payloadFromPost(post *reddit.Thing) *payload.Payload {
|
func payloadFromPost(post *reddit.Thing) *payload.Payload {
|
||||||
subtitle := fmt.Sprintf("r/%s", post.Subreddit)
|
|
||||||
|
|
||||||
payload := payload.
|
payload := payload.
|
||||||
NewPayload().
|
NewPayload().
|
||||||
AlertSubtitle(subtitle).
|
|
||||||
AlertBody(post.Title).
|
|
||||||
AlertSummaryArg(post.Subreddit).
|
AlertSummaryArg(post.Subreddit).
|
||||||
Category("post-watch").
|
Category("post-watch").
|
||||||
Custom("post_title", post.Title).
|
Custom("post_title", post.Title).
|
||||||
|
|
Loading…
Reference in a new issue