Add post thumbnails too

This commit is contained in:
Andre Medeiros 2022-05-01 13:33:09 -04:00
parent 63344348df
commit 9ba4498c08
3 changed files with 13 additions and 1 deletions

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}