From 3c3f81e548b05f2ee7d547fcc816d963d37c05ff Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Thu, 23 Jan 2020 18:08:15 -0500 Subject: [PATCH] experimental reactions --- activity.go | 7 +++++++ database.go | 3 +++ docs/changelog.txt | 2 ++ honk.go | 6 ++++++ views/honk.html | 5 +++++ web.go | 12 ++++++++++++ 6 files changed, 35 insertions(+) diff --git a/activity.go b/activity.go index 6327222..4099b54 100644 --- a/activity.go +++ b/activity.go @@ -1152,6 +1152,13 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) { if h.Convoy != "" { j["context"] = h.Convoy } + case "react": + j["type"] = "EmojiReaction" + j["object"] = h.XID + if h.Convoy != "" { + j["context"] = h.Convoy + } + j["content"] = user.Options.Reaction case "deack": b := junk.New() b["id"] = user.URL + "/" + "ack" + "/" + shortxid(h.XID) diff --git a/database.go b/database.go index e982f45..5d1e5fb 100644 --- a/database.go +++ b/database.go @@ -50,6 +50,9 @@ func userfromrow(row *sql.Row) (*WhatAbout, error) { } else { user.URL = fmt.Sprintf("https://%s/%s", serverName, user.Name) } + if user.Options.Reaction == "" { + user.Options.Reaction = "😞" + } return user, nil } diff --git a/docs/changelog.txt b/docs/changelog.txt index 069555b..0aa4a4f 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog === next +--- Add Reactions. + + Quick fix to hide all images. + Allow resending follow requests. diff --git a/honk.go b/honk.go index 86befa0..6d812fe 100644 --- a/honk.go +++ b/honk.go @@ -51,6 +51,7 @@ type UserOptions struct { OmitImages bool `json:",omitempty"` Avatar string `json:",omitempty"` MapLink string `json:",omitempty"` + Reaction string `json:",omitempty"` } type KeyInfo struct { @@ -108,6 +109,7 @@ const ( flagIsBonked = 2 flagIsSaved = 4 flagIsUntagged = 8 + flagIsReacted = 16 ) func (honk *Honk) IsAcked() bool { @@ -126,6 +128,10 @@ func (honk *Honk) IsUntagged() bool { return honk.Flags&flagIsUntagged != 0 } +func (honk *Honk) IsReacted() bool { + return honk.Flags&flagIsReacted != 0 +} + type Donk struct { FileID int64 XID string diff --git a/views/honk.html b/views/honk.html index d52523c..24229ee 100644 --- a/views/honk.html +++ b/views/honk.html @@ -121,6 +121,11 @@ in reply to: {{ .RID }} {{ end }} +{{ if .Honk.IsReacted }} + +{{ else }} + +{{ end }}

diff --git a/web.go b/web.go index f9c8a9e..18e9e48 100644 --- a/web.go +++ b/web.go @@ -1267,6 +1267,18 @@ func zonkit(w http.ResponseWriter, r *http.Request) { return } + if wherefore == "react" { + xonk := getxonk(userinfo.UserID, what) + if xonk != nil { + _, err := stmtUpdateFlags.Exec(flagIsReacted, xonk.ID) + if err != nil { + log.Printf("error saving: %s", err) + } + sendzonkofsorts(xonk, user, "react") + } + return + } + // my hammer is too big, oh well defer oldjonks.Flush()