-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.go
51 lines (40 loc) · 1.22 KB
/
actions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"context"
"log"
"github.com/a-h/gemini"
"github.com/mattn/go-mastodon"
"github.com/mibzman/titan"
)
func composeTootHandler(w gemini.ResponseWriter, r *gemini.Request) {
TootContent := titan.GetQuery(r)
toot := mastodon.Toot{}
toot.Status = TootContent
mastodonClient.PostStatus(context.Background(), &toot)
w.SetHeader(gemini.CodeRedirect, "/timeline")
}
func replyTootHandler(w gemini.ResponseWriter, r *gemini.Request) {
ID := titan.GetVar(r, "ID")
TootContent := titan.GetQuery(r)
toot := mastodon.Toot{}
toot.Status = TootContent
toot.InReplyToID = mastodon.ID(ID)
mastodonClient.PostStatus(context.Background(), &toot)
w.SetHeader(gemini.CodeRedirect, "/toot/"+ID)
}
func boostTootHandler(w gemini.ResponseWriter, r *gemini.Request) {
ID := titan.GetVar(r, "ID")
_, err := mastodonClient.Reblog(context.Background(), mastodon.ID(ID))
if err != nil {
log.Fatal("error:", err)
}
w.SetHeader(gemini.CodeRedirect, "/toot/"+ID)
}
func favTootHandler(w gemini.ResponseWriter, r *gemini.Request) {
ID := titan.GetVar(r, "ID")
_, err := mastodonClient.Favourite(context.Background(), mastodon.ID(ID))
if err != nil {
log.Fatal("error:", err)
}
w.SetHeader(gemini.CodeRedirect, "/toot/"+ID)
}