mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 11:14:28 +00:00
Fix the migration handler
This commit is contained in:
parent
68695fed39
commit
340d915599
1 changed files with 20 additions and 17 deletions
37
app.py
37
app.py
|
@ -465,23 +465,26 @@ def tmp_migrate():
|
||||||
@login_required
|
@login_required
|
||||||
def tmp_migrate2():
|
def tmp_migrate2():
|
||||||
for activity in DB.activities.find():
|
for activity in DB.activities.find():
|
||||||
if (
|
try:
|
||||||
activity["box"] == Box.OUTBOX.value
|
if (
|
||||||
and activity["type"] == ActivityType.LIKE.value
|
activity["box"] == Box.OUTBOX.value
|
||||||
):
|
and activity["type"] == ActivityType.LIKE.value
|
||||||
like = ap.parse_activity(activity["activity"])
|
):
|
||||||
obj = like.get_object()
|
like = ap.parse_activity(activity["activity"])
|
||||||
DB.activities.update_one(
|
obj = like.get_object()
|
||||||
{"remote_id": like.id},
|
DB.activities.update_one(
|
||||||
{"$set": {"meta.object": obj.to_dict(embed=True)}},
|
{"remote_id": like.id},
|
||||||
)
|
{"$set": {"meta.object": obj.to_dict(embed=True)}},
|
||||||
elif activity["type"] == ActivityType.ANNOUNCE.value:
|
)
|
||||||
announce = ap.parse_activity(activity["activity"])
|
elif activity["type"] == ActivityType.ANNOUNCE.value:
|
||||||
obj = announce.get_object()
|
announce = ap.parse_activity(activity["activity"])
|
||||||
DB.activities.update_one(
|
obj = announce.get_object()
|
||||||
{"remote_id": announce.id},
|
DB.activities.update_one(
|
||||||
{"$set": {"meta.object": obj.to_dict(embed=True)}},
|
{"remote_id": announce.id},
|
||||||
)
|
{"$set": {"meta.object": obj.to_dict(embed=True)}},
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
return "Done"
|
return "Done"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue