Bladeren bron

Support AP-style mentions of centralized social media accounts

This allows users to mention users on the following non-ActivityPub
social media sites:

- twitter.com
- medium.com

It also adds missing error handling in federatePost().
pull/319/head
Matt Baer 4 jaren geleden
bovenliggende
commit
507acc7e1c
3 gewijzigde bestanden met toevoegingen van 25 en 0 verwijderingen
  1. +4
    -0
      activitypub.go
  2. +11
    -0
      database.go
  3. +10
    -0
      silobridge.go

+ 4
- 0
activitypub.go Bestand weergeven

@@ -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)


+ 11
- 0
database.go Bestand weergeven

@@ -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


+ 10
- 0
silobridge.go Bestand weergeven

@@ -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": "@",
}

Laden…
Annuleren
Opslaan