Fix poll for Pleroma
This commit is contained in:
parent
8ed8a436e5
commit
733d6c0ca5
2 changed files with 21 additions and 2 deletions
|
@ -83,6 +83,18 @@ def _answer_key(choice: str) -> str:
|
||||||
return h.hexdigest()
|
return h.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def _is_local_reply(create: ap.Create) -> bool:
|
||||||
|
for dest in _to_list(create.to or []):
|
||||||
|
if dest.startswith(BASE_URL):
|
||||||
|
return True
|
||||||
|
|
||||||
|
for dest in _to_list(create.cc or []):
|
||||||
|
if dest.startswith(BASE_URL):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class Box(Enum):
|
class Box(Enum):
|
||||||
INBOX = "inbox"
|
INBOX = "inbox"
|
||||||
OUTBOX = "outbox"
|
OUTBOX = "outbox"
|
||||||
|
@ -641,7 +653,7 @@ class MicroblogPubBackend(Backend):
|
||||||
if (
|
if (
|
||||||
reply.id.startswith(BASE_URL)
|
reply.id.startswith(BASE_URL)
|
||||||
and reply.has_type(ap.ActivityType.QUESTION.value)
|
and reply.has_type(ap.ActivityType.QUESTION.value)
|
||||||
and _to_list(create.get_object().to)[0].startswith(BASE_URL)
|
and _is_local_reply(create)
|
||||||
and not create.is_public()
|
and not create.is_public()
|
||||||
):
|
):
|
||||||
return self._process_question_reply(create, reply)
|
return self._process_question_reply(create, reply)
|
||||||
|
|
9
app.py
9
app.py
|
@ -1594,6 +1594,7 @@ def admin_notifications():
|
||||||
replies_query = {
|
replies_query = {
|
||||||
"type": ActivityType.CREATE.value,
|
"type": ActivityType.CREATE.value,
|
||||||
"activity.object.inReplyTo": {"$regex": f"^{BASE_URL}"},
|
"activity.object.inReplyTo": {"$regex": f"^{BASE_URL}"},
|
||||||
|
"meta.poll_answer": False,
|
||||||
}
|
}
|
||||||
announced_query = {
|
announced_query = {
|
||||||
"type": ActivityType.ANNOUNCE.value,
|
"type": ActivityType.ANNOUNCE.value,
|
||||||
|
@ -2163,7 +2164,13 @@ def api_new_question():
|
||||||
a = _user_api_arg(f"answer{i}", default=None)
|
a = _user_api_arg(f"answer{i}", default=None)
|
||||||
if not a:
|
if not a:
|
||||||
break
|
break
|
||||||
answers.append({"type": ActivityType.NOTE.value, "name": a})
|
answers.append(
|
||||||
|
{
|
||||||
|
"type": ActivityType.NOTE.value,
|
||||||
|
"name": a,
|
||||||
|
"replies": {"type": ActivityType.COLLECTION.value, "totalItems": 0},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
open_for = int(_user_api_arg("open_for"))
|
open_for = int(_user_api_arg("open_for"))
|
||||||
choices = {
|
choices = {
|
||||||
|
|
Loading…
Reference in a new issue