aboutsummaryrefslogtreecommitdiff
path: root/server.py
diff options
context:
space:
mode:
authorAnthony Wang2023-01-18 20:33:39 +0000
committerAnthony Wang2023-01-18 20:33:39 +0000
commitf054570ee25fdd33cdd4770939c1c47c73ac9ddf (patch)
tree0a6005da74f6e10ba370b14d61d7b52e48888aaf /server.py
parenta56c2664dc3facfed7f8ec2bbe3ab36f1f5803f0 (diff)
Add to following collection only after receiving Accept activity
Diffstat (limited to 'server.py')
-rw-r--r--server.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/server.py b/server.py
index cbd5602..c76b0e7 100644
--- a/server.py
+++ b/server.py
@@ -95,11 +95,16 @@ class fuwuqi(SimpleHTTPRequestHandler):
if self.path.endswith('inbox'):
# S2S
- collection_append(f'users/{username}.inbox', activity)
+ collection_append(username, 'inbox', activity)
+ if activity['type'] == 'Accept' and activity['actor'] == activity['object']['object']:
+ # Follow request accepted
+ collection_append(username, 'following', activity['actor'])
elif self.path.endswith('outbox'):
# C2S
- collection_append(f'users/{username}.outbox', activity)
+ collection_append(username, 'outbox', activity)
# Clients responsible for addressing activity
+ if type(activity['to']) is not list:
+ activity['to'] = [activity['to']]
for to in activity['to']:
if 'followers' in to or to == 'https://www.w3.org/ns/activitystreams#Public':
with open(f'users/{username}.followers') as f:
@@ -116,9 +121,6 @@ class fuwuqi(SimpleHTTPRequestHandler):
elif activity['type'] == 'Accept':
# Accept follow request
collection_append(username, 'followers', activity['object']['actor'])
- elif activity['type'] == 'Follow':
- # Follow request
- collection_append(username, 'following', activity['object'])
elif activity['type'] == 'Like':
# Like post
collection_append(username, 'liked', activity['object'])