diff --git a/activitypub.go b/activitypub.go index 328284f..d34e70c 100644 --- a/activitypub.go +++ b/activitypub.go @@ -699,6 +699,10 @@ func federatePost(app *App, p *PublicPost, collID int64, isUpdate bool) error { // I don't believe we'd ever have too many mentions in a single post that this // could become a burden. remoteUser, err := getRemoteUser(app, tag.HRef) + if err != nil { + log.Error("Unable to find remote user %s. Skipping: %v", tag.HRef, err) + continue + } err = makeActivityPost(app.cfg.App.Host, actor, remoteUser.Inbox, activity) if err != nil { log.Error("Couldn't post! %v", err) diff --git a/database.go b/database.go index 0eee612..a878010 100644 --- a/database.go +++ b/database.go @@ -2652,6 +2652,17 @@ func handleFailedPostInsert(err error) error { func (db *datastore) GetProfilePageFromHandle(app *App, handle string) (string, error) { handle = strings.TrimLeft(handle, "@") actorIRI := "" + parts := strings.Split(handle, "@") + if len(parts) != 2 { + return "", fmt.Errorf("invalid handle format") + } + domain := parts[1] + + // Check non-AP instances + if prefix, ok := fakeAPInstances[domain]; ok { + return "https://" + domain + "/" + prefix + parts[0], nil + } + remoteUser, err := getRemoteUserFromHandle(app, handle) if err != nil { // can't find using handle in the table but the table may already have this user without diff --git a/silobridge.go b/silobridge.go new file mode 100644 index 0000000..dcd4c9f --- /dev/null +++ b/silobridge.go @@ -0,0 +1,10 @@ +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": "@", +}