mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Fix queries for index/outbox
This commit is contained in:
parent
5b1e776fa2
commit
151ced0b41
1 changed files with 25 additions and 10 deletions
35
app.py
35
app.py
|
@ -109,9 +109,14 @@ else:
|
||||||
def inject_config():
|
def inject_config():
|
||||||
q = {
|
q = {
|
||||||
**in_outbox(),
|
**in_outbox(),
|
||||||
**by_type([ActivityType.CREATE, ActivityType.ANNOUNCE]),
|
"$or": [
|
||||||
**not_deleted(),
|
{
|
||||||
**by_visibility(ap.Visibility.PUBLIC),
|
**by_type(ActivityType.CREATE),
|
||||||
|
**not_deleted(),
|
||||||
|
**by_visibility(ap.Visibility.PUBLIC),
|
||||||
|
},
|
||||||
|
{**by_type(ActivityType.ANNOUNCE), **not_undo()},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
notes_count = DB.activities.count(q)
|
notes_count = DB.activities.count(q)
|
||||||
# FIXME(tsileo): rename to all_count, and remove poll answers from it
|
# FIXME(tsileo): rename to all_count, and remove poll answers from it
|
||||||
|
@ -348,10 +353,15 @@ def index():
|
||||||
|
|
||||||
q = {
|
q = {
|
||||||
**in_outbox(),
|
**in_outbox(),
|
||||||
**by_type([ActivityType.CREATE, ActivityType.ANNOUNCE]),
|
"$or": [
|
||||||
**not_deleted(),
|
{
|
||||||
**by_visibility(ap.Visibility.PUBLIC),
|
**by_type(ActivityType.CREATE),
|
||||||
"$or": [{"meta.pinned": False}, {"meta.pinned": {"$exists": False}}],
|
**not_deleted(),
|
||||||
|
**by_visibility(ap.Visibility.PUBLIC),
|
||||||
|
"$or": [{"meta.pinned": False}, {"meta.pinned": {"$exists": False}}],
|
||||||
|
},
|
||||||
|
{**by_type(ActivityType.ANNOUNCE), **not_undo()},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
apinned = []
|
apinned = []
|
||||||
|
@ -478,9 +488,14 @@ def outbox():
|
||||||
# TODO(tsileo): returns the whole outbox if authenticated and look at OCAP support
|
# TODO(tsileo): returns the whole outbox if authenticated and look at OCAP support
|
||||||
q = {
|
q = {
|
||||||
**in_outbox(),
|
**in_outbox(),
|
||||||
**by_type([ActivityType.CREATE, ActivityType.ANNOUNCE]),
|
"$or": [
|
||||||
**not_deleted(),
|
{
|
||||||
**by_visibility(ap.Visibility.PUBLIC),
|
**by_type(ActivityType.CREATE),
|
||||||
|
**not_deleted(),
|
||||||
|
**by_visibility(ap.Visibility.PUBLIC),
|
||||||
|
},
|
||||||
|
{**by_type(ActivityType.ANNOUNCE), **not_undo()},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
return activitypubify(
|
return activitypubify(
|
||||||
**activitypub.build_ordered_collection(
|
**activitypub.build_ordered_collection(
|
||||||
|
|
Loading…
Reference in a new issue