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
|
package urls
import (
"fmt"
"net/url"
)
func linkTo(name, base string, path ...string) (*url.URL, error) {
u, err := url.JoinPath(base, path...)
if err != nil {
return nil, fmt.Errorf("could not build %s url: %w", name, err)
}
u, err = url.PathUnescape(u)
if err != nil {
return nil, fmt.Errorf("could not unescape %s url: %w", name, err)
}
uri, err := url.Parse(u)
if err != nil {
return nil, fmt.Errorf("could not parse %s url: %w", name, err)
}
return uri, err
}
func UrlInbox(name, domain string) (*url.URL, error) {
return linkTo("inbox", domain, "actors", name, "inbox")
}
func UrlOutbox(name, domain string) (*url.URL, error) {
return linkTo("outbox", domain, "actors", name, "outbox")
}
func UrlProfile(name, domain string) (*url.URL, error) {
return linkTo("outbox", domain, "actors", name)
}
func UrlProfileKey(name, domain string) (*url.URL, error) {
return linkTo("outbox", domain, "actors", name+"#key")
}
func UrlActorAvatar(name, domain string) (*url.URL, error) {
return linkTo("outbox", domain, "actors", name, "avatar")
}
func UrlFollowers(name, domain string) (*url.URL, error) {
return linkTo("outbox", domain, "actors", name, "followers")
}
func UrlFollowing(name, domain string) (*url.URL, error) {
return linkTo("outbox", domain, "actors", name, "following")
}
func UrlActivity(name, domain, id string) (*url.URL, error) {
return linkTo("activity", domain, "actors", name, "activity", id)
}
func UrlNote(name, domain, id string) (*url.URL, error) {
return linkTo("note", domain, "actors", name, "activity", id, "note")
}
|