- pub async fn delete_account(pool: &DbPool, person_id: PersonId) -> Result<Person, Error> {
- use crate::schema::local_user;
+ /// Update or insert the person.
+ ///
+ /// This is necessary for federation, because Activitypub doesnt distinguish between these actions.
+ pub async fn upsert(pool: &mut DbPool<'_>, form: &PersonInsertForm) -> Result<Self, Error> {
+ let conn = &mut get_conn(pool).await?;
+ insert_into(person::table)
+ .values(form)
+ .on_conflict(person::actor_id)
+ .do_update()
+ .set(form)
+ .get_result::<Self>(conn)
+ .await
+ }
+ pub async fn delete_account(pool: &mut DbPool<'_>, person_id: PersonId) -> Result<Person, Error> {