Prevent two activities from being bookmarked at once
This could happen when bookmarking via an Announce when the original Create is also in the DB.
This commit is contained in:
parent
9e1bd06879
commit
5b76fe65aa
1 changed files with 7 additions and 5 deletions
12
app.py
12
app.py
|
@ -1727,12 +1727,14 @@ def api_bookmark():
|
|||
|
||||
undo = _user_api_arg("undo", default=None) == "yes"
|
||||
|
||||
DB.activities.update_one(
|
||||
{"meta.object.id": note.id}, {"$set": {"meta.bookmarked": not undo}}
|
||||
)
|
||||
DB.activities.update_one(
|
||||
# Try to bookmark the `Create` first
|
||||
if not DB.activities.update_one(
|
||||
{"activity.object.id": note.id}, {"$set": {"meta.bookmarked": not undo}}
|
||||
)
|
||||
).modified_count:
|
||||
# Then look for the `Announce`
|
||||
DB.activities.update_one(
|
||||
{"meta.object.id": note.id}, {"$set": {"meta.bookmarked": not undo}}
|
||||
)
|
||||
|
||||
return _user_api_response()
|
||||
|
||||
|
|
Loading…
Reference in a new issue