Skip to content

Commit 68a680d

Browse files
committed
Add silobridge package
1 parent f54ee17 commit 68a680d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

silobridge/silobridge.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package silobridge
2+
3+
// fakeAPInstances contains a list of sites that we allow writers to mention
4+
// with the @handle@instance.tld syntax, plus the corresponding prefix to
5+
// insert between `https://instance.tld/` and `handle` (e.g.
6+
// https://medium.com/@handle)
7+
var fakeAPInstances = map[string]string{
8+
"deviantart.com": "",
9+
"facebook.com": "",
10+
"flickr.com": "photos/",
11+
"github.com": "",
12+
"instagram.com": "",
13+
"medium.com": "@",
14+
"reddit.com": "user/",
15+
"twitter.com": "",
16+
"wattpad.com": "user/",
17+
"youtube.com": "user/",
18+
}
19+
20+
// Profile returns the full profile URL for a fake ActivityPub instance, based
21+
// on the given handle and domain. If the domain isn't recognized, an empty
22+
// string is returned.
23+
func Profile(handle, domain string) string {
24+
prefix, ok := fakeAPInstances[domain]
25+
if !ok {
26+
return ""
27+
}
28+
return "https://" + domain + "/" + prefix + handle
29+
}

0 commit comments

Comments
 (0)