fix panic on duplicate remoteuser key
this changes handleFetchCollectionInbox to log _all_ errors after attempting to insert an actor in the remoteusers table. previously checking for all errors _except_ duplicate keys would cause a panic if an actor made a request to follow while already having followed.
This commit is contained in:
parent
8557119451
commit
95a98234eb
|
@ -375,11 +375,11 @@ func handleFetchCollectionInbox(app *App, w http.ResponseWriter, r *http.Request
|
||||||
// Add follower locally, since it wasn't found before
|
// Add follower locally, since it wasn't found before
|
||||||
res, err := t.Exec("INSERT INTO remoteusers (actor_id, inbox, shared_inbox) VALUES (?, ?, ?)", fullActor.ID, fullActor.Inbox, fullActor.Endpoints.SharedInbox)
|
res, err := t.Exec("INSERT INTO remoteusers (actor_id, inbox, shared_inbox) VALUES (?, ?, ?)", fullActor.ID, fullActor.Inbox, fullActor.Endpoints.SharedInbox)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !app.db.isDuplicateKeyErr(err) {
|
// if duplicate key, res will be nil and panic on
|
||||||
t.Rollback()
|
// res.LastInsertId below
|
||||||
log.Error("Couldn't add new remoteuser in DB: %v\n", err)
|
t.Rollback()
|
||||||
return
|
log.Error("Couldn't add new remoteuser in DB: %v\n", err)
|
||||||
}
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
followerID, err = res.LastInsertId()
|
followerID, err = res.LastInsertId()
|
||||||
|
|
Loading…
Reference in New Issue