|
1 | 1 | import asyncio |
2 | 2 | import logging |
3 | 3 | import os |
4 | | -import uuid |
5 | 4 | import sys |
| 5 | +import uuid |
| 6 | +from datetime import UTC, datetime |
6 | 7 |
|
7 | | -from apkit.client.asyncio import ActivityPubClient |
8 | | -from apkit.models import Person, CryptographicKey, Like |
9 | | -from cryptography.hazmat.primitives.asymmetric import rsa |
10 | 8 | from cryptography.hazmat.primitives import serialization as crypto_serialization |
11 | | -from datetime import datetime, UTC |
| 9 | +from cryptography.hazmat.primitives.asymmetric import rsa |
| 10 | + |
| 11 | +from apkit.client.asyncio import ActivityPubClient |
| 12 | +from apkit.models import CryptographicKey, Like, Person |
12 | 13 |
|
13 | 14 | if len(sys.argv) < 2: |
14 | 15 | print("USAGE: python like.py <OBJECT_ID>", file=sys.stderr) |
|
65 | 66 | actor = Person( |
66 | 67 | id=f"https://{HOST}/users/{USER_ID}", |
67 | 68 | name="apkit Demo", |
68 | | - preferredUsername="demo", |
| 69 | + preferred_username="demo", |
69 | 70 | summary="This is a demo actor powered by apkit!", |
70 | 71 | inbox=f"https://{HOST}/users/{USER_ID}/inbox", |
71 | 72 | outbox=f"https://{HOST}/users/{USER_ID}/outbox", |
72 | | - publicKey=CryptographicKey( |
| 73 | + public_key=CryptographicKey( |
73 | 74 | id=f"https://{HOST}/users/{USER_ID}#main-key", |
74 | 75 | owner=f"https://{HOST}/users/{USER_ID}", |
75 | | - publicKeyPem=public_key_pem, |
| 76 | + public_key_pem=public_key_pem, |
76 | 77 | ), |
77 | 78 | ) |
78 | 79 |
|
@@ -109,7 +110,10 @@ async def like(object_id: str) -> None: |
109 | 110 | logger.info("Delivering activity...") |
110 | 111 |
|
111 | 112 | resp = await client.post( |
112 | | - inbox_url, key_id=actor.publicKey.id, signature=private_key, json=activity |
| 113 | + inbox_url, |
| 114 | + key_id=actor.publicKey.id, |
| 115 | + signature=private_key, |
| 116 | + json=activity, |
113 | 117 | ) |
114 | 118 | logger.info(f"Delivery result: {resp.status}") |
115 | 119 | logger.info(f"To undo this action, use this URI: {activity.id}") |
|
0 commit comments