Undo like from web interface

master
Bob Mottram 2019-08-01 13:49:16 +01:00
parent 7c7ace43f9
commit f5da898007
2 changed files with 7 additions and 14 deletions

View File

@ -708,7 +708,7 @@ class PubServer(BaseHTTPRequestHandler):
if not self.server.session:
self.server.session= \
createSession(self.server.domain,self.server.port,self.server.useTor)
likeActor=self.server.httpPrefix+'://'+self.server.fullDomain+'/users/'+self.postToNickname
likeActor=self.server.httpPrefix+'://'+self.server.domainFull+'/users/'+self.postToNickname
likeJson= {
'type': 'Like',
'actor': likeActor,
@ -730,7 +730,7 @@ class PubServer(BaseHTTPRequestHandler):
if not self.server.session:
self.server.session= \
createSession(self.server.domain,self.server.port,self.server.useTor)
undoActor=self.server.httpPrefix+'://'+self.server.fullDomain+'/users/'+self.postToNickname
undoActor=self.server.httpPrefix+'://'+self.server.domainFull+'/users/'+self.postToNickname
undoLikeJson= {
'type': 'Undo',
'actor': undoActor,
@ -743,7 +743,7 @@ class PubServer(BaseHTTPRequestHandler):
},
'to': [undoActor+'/followers'],
'cc': []
}
}
if undoLikeJson:
self._postToOutbox(undoLikeJson)
self.server.GETbusy=False

15
like.py
View File

@ -19,9 +19,9 @@ from webfinger import webfingerHandle
from auth import createBasicAuthHeader
from posts import getPersonBox
def undoLikesCollectionEntry(postFilename: str,objectUrl: str, actor: str,debug: bool) -> None:
def undoLikesCollectionEntry(postFilename: str,objectUrl: str,actor: str,debug: bool) -> None:
"""Undoes a like for a particular actor
"""
"""
with open(postFilename, 'r') as fp:
postJsonObject=commentjson.load(fp)
if not postJsonObject.get('type'):
@ -480,22 +480,15 @@ def outboxUndoLike(baseDir: str,httpPrefix: str, \
""" When an undo like request is received by the outbox from c2s
"""
if not messageJson.get('type'):
if debug:
print('DEBUG: undo like - no type')
return
if not messageJson['type']=='Undo':
if debug:
print('DEBUG: not an undo of Like')
return
if not messageJson.get('object'):
if debug:
print('DEBUG: no object in undo like')
return
if not isinstance(messageJson['object']['object'], dict):
if not isinstance(messageJson['object'], dict):
if debug:
print('DEBUG: undo like object is not dict')
return
return
if not messageJson['object'].get('type'):
if debug:
print('DEBUG: undo like - no type')