Make POST /contributors API idempotent
Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
parent
1981de4cae
commit
6c937c4a90
1 changed files with 9 additions and 3 deletions
|
@ -37,11 +37,17 @@ impl Database {
|
||||||
&*tx,
|
&*tx,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
contributor::ActiveModel {
|
|
||||||
|
contributor::Entity::insert(contributor::ActiveModel {
|
||||||
user_id: ActiveValue::Set(user.id),
|
user_id: ActiveValue::Set(user.id),
|
||||||
signed_at: ActiveValue::NotSet,
|
signed_at: ActiveValue::NotSet,
|
||||||
}
|
})
|
||||||
.insert(&*tx)
|
.on_conflict(
|
||||||
|
OnConflict::column(contributor::Column::UserId)
|
||||||
|
.do_nothing()
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.exec_without_returning(&*tx)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue