This commit is contained in:
parent
440399f8d2
commit
c70928ec7b
1 changed files with 22 additions and 1 deletions
|
@ -747,10 +747,31 @@ func handleCreate(w http.ResponseWriter, r *http.Request, object map[string]any)
|
||||||
if objectNote.Summary != nil {
|
if objectNote.Summary != nil {
|
||||||
dbNote.ContentWarning = sql.NullString{Valid: true, String: *objectNote.Summary}
|
dbNote.ContentWarning = sql.NullString{Valid: true, String: *objectNote.Summary}
|
||||||
}
|
}
|
||||||
err = dbgen.Note.Create(&dbNote)
|
tx := dbgen.Q.Begin()
|
||||||
|
err = tx.Note.Create(&dbNote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
_ = tx.Rollback()
|
||||||
log.Error().Err(err).Any("note", dbNote).Msg("Failed to create note in db")
|
log.Error().Err(err).Any("note", dbNote).Msg("Failed to create note in db")
|
||||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
createActivity := models.Activity{
|
||||||
|
Type: string(models.ActivityCreate),
|
||||||
|
Id: object["id"].(string),
|
||||||
|
ObjectId: dbNote.ID,
|
||||||
|
ObjectType: uint32(models.ActivitystreamsActivityTargetNote),
|
||||||
|
}
|
||||||
|
err = tx.Activity.Create(&createActivity)
|
||||||
|
if err != nil {
|
||||||
|
_ = tx.Rollback()
|
||||||
|
log.Error().Err(err).Any("note", dbNote).Msg("Failed to create note create activity in db")
|
||||||
|
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = tx.Commit()
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Any("note", dbNote).Msg("Failed to submit note creation in db")
|
||||||
|
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue