-
Notifications
You must be signed in to change notification settings - Fork 0
/
activitypub.go
60 lines (48 loc) · 1.32 KB
/
activitypub.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
52
53
54
55
56
57
58
59
60
package main
import (
"io"
"net/http"
)
var apActor = `{
"subject": "acct:piusbird@treefort.piusbird.space",
"aliases": [
"https://treefort.piusbird.space/@piusbird",
"https://treefort.piusbird.space/users/piusbird"
],
"links": [
{
"rel": "self",
"type": "application/activity+json",
"href": "https://treefort.piusbird.space/u/piusbird"
}
]
}
`
var user = `{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1"
],
"id": "https://treefort.piusbird.space/u/piusbird",
"type": "Person",
"preferredUsername": "piusbird",
"name": "Pius the Unscrootched",
"summary": "Server Server Server",
"manuallyApprovesFollowers": true,
"discoverable": true,
"published": "2019-04-20T00:00:00Z",
"inbox": "https://treefort.piusbird.space/inbox",
"outbox": "https://treefort.piusbird.space/outbox",
}
`
func webfingeRequest(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/activity+json")
io.WriteString(w, apActor)
}
func serveUser(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/activity+json")
io.WriteString(w, user)
}
func serveProfileHtml(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "https://treefort.piusbird.space/index", http.StatusMovedPermanently)
}