Add support to update Poll by AP (#514)

pull/515/head
Humberto Rocha 2023-02-18 12:38:31 -05:00 zatwierdzone przez GitHub
rodzic e43d0a052c
commit 79aea1b8ba
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 41 dodań i 1 usunięć

Wyświetl plik

@ -293,6 +293,46 @@ def test_content_map_question(remote_identity: Identity):
)
assert post.content == "Test Question"
assert isinstance(post.type_data, QuestionData)
assert post.type_data.voter_count == 10
# test the update case
question_id = post.id
post = Post.by_ap(
data={
"id": "https://remote.test/posts/1/",
"type": "Question",
"votersCount": 100,
"closed": "2023-01-01T26:04:45Z",
"content": "Test Question",
"attributedTo": "https://remote.test/test-actor/",
"published": "2022-12-23T10:50:54Z",
"endTime": "2023-01-01T20:04:45Z",
"oneOf": [
{
"type": "Note",
"name": "Option 1",
"replies": {
"type": "Collection",
"totalItems": 60,
},
},
{
"type": "Note",
"name": "Option 2",
"replies": {
"type": "Collection",
"totalItems": 40,
},
},
],
},
create=False,
update=True,
)
assert isinstance(post.type_data, QuestionData)
assert post.type_data.voter_count == 100
assert post.id == question_id
@pytest.mark.django_db

Wyświetl plik

@ -61,7 +61,7 @@ class InboxMessageStates(StateGraph):
case "application":
await sync_to_async(Identity.handle_update_ap)(instance.message)
case "question":
pass # Drop for now
await sync_to_async(Post.handle_update_ap)(instance.message)
case unknown:
if unknown in Post.Types.names:
await sync_to_async(Post.handle_update_ap)(instance.message)