mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-13 07:27:43 +00:00
Add post thumbnails too
This commit is contained in:
parent
63344348df
commit
9ba4498c08
3 changed files with 13 additions and 1 deletions
|
@ -79,6 +79,7 @@ type Thing struct {
|
|||
Title string `json:"title"`
|
||||
URL string `json:"url"`
|
||||
Flair string `json:"flair"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
}
|
||||
|
||||
func (t *Thing) FullName() string {
|
||||
|
@ -114,6 +115,7 @@ func NewThing(val *fastjson.Value) *Thing {
|
|||
t.SelfText = string(data.GetStringBytes("selftext"))
|
||||
t.URL = string(data.GetStringBytes("url"))
|
||||
t.Flair = string(data.GetStringBytes("link_flair_text"))
|
||||
t.Thumbnail = string(data.GetStringBytes("thumbnail"))
|
||||
|
||||
return t
|
||||
}
|
||||
|
|
|
@ -447,5 +447,9 @@ func payloadFromPost(post *reddit.Thing) *payload.Payload {
|
|||
MutableContent().
|
||||
Sound("traloop.wav")
|
||||
|
||||
if post.Thumbnail != "" {
|
||||
payload.Custom("thumbnail", post.Thumbnail)
|
||||
}
|
||||
|
||||
return payload
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ func (tc *trendingConsumer) Consume(delivery rmq.Delivery) {
|
|||
func payloadFromTrendingPost(post *reddit.Thing) *payload.Payload {
|
||||
title := fmt.Sprintf(trendingNotificationTitleFormat, post.Subreddit)
|
||||
|
||||
return payload.
|
||||
payload := payload.
|
||||
NewPayload().
|
||||
AlertTitle(title).
|
||||
AlertBody(post.Title).
|
||||
|
@ -331,4 +331,10 @@ func payloadFromTrendingPost(post *reddit.Thing) *payload.Payload {
|
|||
Custom("post_age", post.CreatedAt).
|
||||
MutableContent().
|
||||
Sound("traloop.wav")
|
||||
|
||||
if post.Thumbnail != "" {
|
||||
payload.Custom("thumbnail", post.Thumbnail)
|
||||
}
|
||||
|
||||
return payload
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue