mirror of
https://git.exozy.me/a/fuwuqi.git
synced 2024-11-25 04:11:01 +00:00
Add to following collection only after receiving Accept activity
This commit is contained in:
parent
a56c2664dc
commit
f054570ee2
1 changed files with 7 additions and 5 deletions
12
server.py
12
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'])
|
||||
|
|
Loading…
Reference in a new issue