Move fakeAPInstances to web-core/silobridge package

This adds support for mentioning profiles on the following sites:

- deviantart.com
- facebook.com
- flickr.com
- github.com
- instagram.com
- reddit.com
- wattpad.com
- youtube.com
This commit is contained in:
Matt Baer 2020-08-13 12:33:35 -04:00
parent 507acc7e1c
commit 7fa78c2255
4 changed files with 6 additions and 13 deletions

View File

@ -14,6 +14,7 @@ import (
"context"
"database/sql"
"fmt"
"github.com/writeas/web-core/silobridge"
wf_db "github.com/writeas/writefreely/db"
"net/http"
"strings"
@ -2659,8 +2660,8 @@ func (db *datastore) GetProfilePageFromHandle(app *App, handle string) (string,
domain := parts[1]
// Check non-AP instances
if prefix, ok := fakeAPInstances[domain]; ok {
return "https://" + domain + "/" + prefix + parts[0], nil
if siloProfileURL := silobridge.Profile(parts[0], domain); siloProfileURL != "" {
return siloProfileURL, nil
}
remoteUser, err := getRemoteUserFromHandle(app, handle)

2
go.mod
View File

@ -46,7 +46,7 @@ require (
github.com/writeas/nerds v1.0.0
github.com/writeas/saturday v1.7.2-0.20200427193424-392b95a03320
github.com/writeas/slug v1.2.0
github.com/writeas/web-core v1.2.0
github.com/writeas/web-core v1.2.1-0.20200813161734-68a680d1b03c
github.com/writefreely/go-nodeinfo v1.2.0
golang.org/x/crypto v0.0.0-20200109152110-61a87790db17
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 // indirect

2
go.sum
View File

@ -167,6 +167,8 @@ github.com/writeas/slug v1.2.0 h1:EMQ+cwLiOcA6EtFwUgyw3Ge18x9uflUnOnR6bp/J+/g=
github.com/writeas/slug v1.2.0/go.mod h1:RE8shOqQP3YhsfsQe0L3RnuejfQ4Mk+JjY5YJQFubfQ=
github.com/writeas/web-core v1.2.0 h1:CYqvBd+byi1cK4mCr1NZ6CjILuMOFmiFecv+OACcmG0=
github.com/writeas/web-core v1.2.0/go.mod h1:vTYajviuNBAxjctPp2NUYdgjofywVkxUGpeaERF3SfI=
github.com/writeas/web-core v1.2.1-0.20200813161734-68a680d1b03c h1:/aPb8WKtC+Ga/xUEcME0iX3VKBeeJ02kXCaROaZ21SE=
github.com/writeas/web-core v1.2.1-0.20200813161734-68a680d1b03c/go.mod h1:vTYajviuNBAxjctPp2NUYdgjofywVkxUGpeaERF3SfI=
github.com/writefreely/go-nodeinfo v1.2.0 h1:La+YbTCvmpTwFhBSlebWDDL81N88Qf/SCAvRLR7F8ss=
github.com/writefreely/go-nodeinfo v1.2.0/go.mod h1:UTvE78KpcjYOlRHupZIiSEFcXHioTXuacCbHU+CAcPg=
golang.org/x/crypto v0.0.0-20180527072434-ab813273cd59 h1:hk3yo72LXLapY9EXVttc3Z1rLOxT9IuAPPX3GpY2+jo=

View File

@ -1,10 +0,0 @@
package writefreely
// fakeAPInstances contains a list of sites that we allow writers to mention
// with the @handle@instance.tld syntax, plus the corresponding prefix to
// insert between `https://instance.tld/` and `handle` (e.g.
// https://medium.com/@handle)
var fakeAPInstances = map[string]string{
"twitter.com": "",
"medium.com": "@",
}