Fix queries for index/outbox

This commit is contained in:
Thomas Sileo 2019-09-01 21:49:36 +02:00
parent 5b1e776fa2
commit 151ced0b41

35
app.py
View file

@ -109,9 +109,14 @@ else:
def inject_config():
q = {
**in_outbox(),
**by_type([ActivityType.CREATE, ActivityType.ANNOUNCE]),
**not_deleted(),
**by_visibility(ap.Visibility.PUBLIC),
"$or": [
{
**by_type(ActivityType.CREATE),
**not_deleted(),
**by_visibility(ap.Visibility.PUBLIC),
},
{**by_type(ActivityType.ANNOUNCE), **not_undo()},
],
}
notes_count = DB.activities.count(q)
# FIXME(tsileo): rename to all_count, and remove poll answers from it
@ -348,10 +353,15 @@ def index():
q = {
**in_outbox(),
**by_type([ActivityType.CREATE, ActivityType.ANNOUNCE]),
**not_deleted(),
**by_visibility(ap.Visibility.PUBLIC),
"$or": [{"meta.pinned": False}, {"meta.pinned": {"$exists": False}}],
"$or": [
{
**by_type(ActivityType.CREATE),
**not_deleted(),
**by_visibility(ap.Visibility.PUBLIC),
"$or": [{"meta.pinned": False}, {"meta.pinned": {"$exists": False}}],
},
{**by_type(ActivityType.ANNOUNCE), **not_undo()},
],
}
apinned = []
@ -478,9 +488,14 @@ def outbox():
# TODO(tsileo): returns the whole outbox if authenticated and look at OCAP support
q = {
**in_outbox(),
**by_type([ActivityType.CREATE, ActivityType.ANNOUNCE]),
**not_deleted(),
**by_visibility(ap.Visibility.PUBLIC),
"$or": [
{
**by_type(ActivityType.CREATE),
**not_deleted(),
**by_visibility(ap.Visibility.PUBLIC),
},
{**by_type(ActivityType.ANNOUNCE), **not_undo()},
],
}
return activitypubify(
**activitypub.build_ordered_collection(