Follow activities

master
Bob Mottram 2019-08-16 22:52:11 +01:00
parent a7ad0c3f9b
commit fb5198d2f6
2 changed files with 16 additions and 14 deletions

View File

@ -2456,15 +2456,17 @@ class PubServer(BaseHTTPRequestHandler):
if self.server.debug: if self.server.debug:
print(followerNickname+' stops following '+followingActor) print(followerNickname+' stops following '+followingActor)
followActor=self.server.httpPrefix+'://'+self.server.domainFull+'/users/'+followerNickname followActor=self.server.httpPrefix+'://'+self.server.domainFull+'/users/'+followerNickname
followId=followActor+'#follows/'+followingNickname
unfollowJson = { unfollowJson = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': followId+'/undo',
'type': 'Undo', 'type': 'Undo',
'actor': followActor, 'actor': followActor,
'object': { 'object': {
'id': followId,
'type': 'Follow', 'type': 'Follow',
'actor': followActor, 'actor': followActor,
'object': followingActor, 'object': followingActor
'to': [followingActor],
'cc': ['https://www.w3.org/ns/activitystreams#Public']
} }
} }
pathUsersSection=self.path.split('/users/')[1] pathUsersSection=self.path.split('/users/')[1]

View File

@ -22,6 +22,7 @@ from posts import getPersonBox
from acceptreject import createAccept from acceptreject import createAccept
from webfinger import webfingerHandle from webfinger import webfingerHandle
from auth import createBasicAuthHeader from auth import createBasicAuthHeader
from auth import createPassword
from session import postJson from session import postJson
def isFollowingActor(baseDir: str,nickname: str,domain: str,actor: str) -> bool: def isFollowingActor(baseDir: str,nickname: str,domain: str,actor: str) -> bool:
@ -490,12 +491,11 @@ def sendFollowRequest(session,baseDir: str, \
followedId=followHttpPrefix+'://'+requestDomain+'/users/'+followNickname followedId=followHttpPrefix+'://'+requestDomain+'/users/'+followNickname
newFollowJson = { newFollowJson = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': followActor+'#follows/'+followNickname,
'type': 'Follow', 'type': 'Follow',
'actor': followActor, 'actor': followActor,
'object': followedId, 'object': followedId
'to': [followedId],
'cc': ['https://www.w3.org/ns/activitystreams#Public'],
'published': published
} }
sendSignedJson(newFollowJson,session,baseDir,nickname,domain,port, \ sendSignedJson(newFollowJson,session,baseDir,nickname,domain,port, \
@ -537,12 +537,11 @@ def sendFollowRequestViaServer(session,fromNickname: str,password: str,
statusNumber,published = getStatusNumber() statusNumber,published = getStatusNumber()
newFollowJson = { newFollowJson = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': followActor+'#follows/'+followNickname,
'type': 'Follow', 'type': 'Follow',
'actor': followActor, 'actor': followActor,
'object': followedId, 'object': followedId
'to': [followedId],
'cc': ['https://www.w3.org/ns/activitystreams#Public'],
'published': published
} }
handle=httpPrefix+'://'+fromDomainFull+'/@'+fromNickname handle=httpPrefix+'://'+fromDomainFull+'/@'+fromNickname
@ -615,14 +614,15 @@ def sendUnfollowRequestViaServer(session,fromNickname: str,password: str,
followedId=httpPrefix+'://'+followDomainFull+'/users/'+followNickname followedId=httpPrefix+'://'+followDomainFull+'/users/'+followNickname
unfollowJson = { unfollowJson = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': followActor+'#follows/'+followNickname+'/undo',
'type': 'Undo', 'type': 'Undo',
'actor': followActor, 'actor': followActor,
'object': { 'object': {
'id': followActor+'#follows/'+followNickname,
'type': 'Follow', 'type': 'Follow',
'actor': followActor, 'actor': followActor,
'object': followedId, 'object': followedId
'to': [followedId],
'cc': ['https://www.w3.org/ns/activitystreams#Public']
} }
} }