Merge pull request #166 from writeas/159-follow-panic
fix panic on duplicate remoteuser key
This commit is contained in:
commit
fcf074cf40
|
@ -375,12 +375,12 @@ 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
|
||||||
|
// res.LastInsertId below
|
||||||
t.Rollback()
|
t.Rollback()
|
||||||
log.Error("Couldn't add new remoteuser in DB: %v\n", err)
|
log.Error("Couldn't add new remoteuser in DB: %v\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
followerID, err = res.LastInsertId()
|
followerID, err = res.LastInsertId()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue