Fix error / info logging around AP mentions

This fixes log formatting and makes verbiage consistent & concise.
pull/282/head
Matt Baer 5 years ago
parent 471a9e0602
commit 97aec9c158
  1. 6
      database.go
  2. 2
      posts.go
  3. 6
      webfinger.go

@ -2618,21 +2618,21 @@ func (db *datastore) GetProfilePageFromHandle(app *App, handle string) (string,
if errRemoteUser == nil { if errRemoteUser == nil {
_, err := app.db.Exec("UPDATE remoteusers SET handle = ? WHERE actor_id = ?", handle, actorIRI) _, err := app.db.Exec("UPDATE remoteusers SET handle = ? WHERE actor_id = ?", handle, actorIRI)
if err != nil { if err != nil {
log.Error("Can't update handle (" + handle + ") in database for user " + actorIRI) log.Error("Couldn't update handle '%s' for user %s", handle, actorIRI)
} }
} else { } else {
// this probably means we don't have the user in the table so let's try to insert it // this probably means we don't have the user in the table so let's try to insert it
// here we need to ask the server for the inboxes // here we need to ask the server for the inboxes
remoteActor, err := activityserve.NewRemoteActor(actorIRI) remoteActor, err := activityserve.NewRemoteActor(actorIRI)
if err != nil { if err != nil {
log.Error("Couldn't fetch remote actor", err) log.Error("Couldn't fetch remote actor: %v", err)
} }
if debugging { if debugging {
log.Info("%s %s %s %s", actorIRI, remoteActor.GetInbox(), remoteActor.GetSharedInbox(), handle) log.Info("%s %s %s %s", actorIRI, remoteActor.GetInbox(), remoteActor.GetSharedInbox(), handle)
} }
_, err = app.db.Exec("INSERT INTO remoteusers (actor_id, inbox, shared_inbox, handle) VALUES(?, ?, ?, ?)", actorIRI, remoteActor.GetInbox(), remoteActor.GetSharedInbox(), handle) _, err = app.db.Exec("INSERT INTO remoteusers (actor_id, inbox, shared_inbox, handle) VALUES(?, ?, ?, ?)", actorIRI, remoteActor.GetInbox(), remoteActor.GetSharedInbox(), handle)
if err != nil { if err != nil {
log.Error("Can't insert remote user in database", err) log.Error("Couldn't insert remote user: %v", err)
return "", err return "", err
} }
} }

@ -1181,7 +1181,7 @@ func (p *PublicPost) ActivityObject(app *App) *activitystreams.Object {
for _, handle := range mentions { for _, handle := range mentions {
actorIRI, err := app.db.GetProfilePageFromHandle(app, handle) actorIRI, err := app.db.GetProfilePageFromHandle(app, handle)
if err != nil { if err != nil {
log.Info("Can't find this user either in the database nor in the remote instance") log.Info("Couldn't find this user locally or remotely")
continue continue
} }
mentionedUsers[handle] = actorIRI mentionedUsers[handle] = actorIRI

@ -101,20 +101,20 @@ func RemoteLookup(handle string) string {
parts := strings.Split(handle, "@") parts := strings.Split(handle, "@")
resp, err := http.Get("https://" + parts[1] + "/.well-known/webfinger?resource=acct:" + handle) resp, err := http.Get("https://" + parts[1] + "/.well-known/webfinger?resource=acct:" + handle)
if err != nil { if err != nil {
log.Error("Error performing webfinger request", err) log.Error("Error on webfinger request: %v", err)
return "" return ""
} }
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
log.Error("Error reading webfinger response", err) log.Error("Error on webfinger response: %v", err)
return "" return ""
} }
var result webfinger.Resource var result webfinger.Resource
err = json.Unmarshal(body, &result) err = json.Unmarshal(body, &result)
if err != nil { if err != nil {
log.Error("Unsupported webfinger response received: %v", err) log.Error("Unable to parse webfinger response: %v", err)
return "" return ""
} }

Loading…
Cancel
Save