forked from indymedia/epicyon
Undo announces via the web interface
parent
c7ecd001a9
commit
7c7ace43f9
10
announce.py
10
announce.py
|
@ -82,19 +82,19 @@ def undoAnnounceCollectionEntry(postFilename: str,actor: str,debug: bool) -> Non
|
|||
if postJsonObject['object']['shares'].get('totalItems'):
|
||||
totalItems=postJsonObject['object']['shares']['totalItems']
|
||||
itemFound=False
|
||||
for likeItem in postJsonObject['object']['shares']['items']:
|
||||
if likeItem.get('actor'):
|
||||
if likeItem['actor']==actor:
|
||||
for announceItem in postJsonObject['object']['shares']['items']:
|
||||
if announceItem.get('actor'):
|
||||
if announceItem['actor']==actor:
|
||||
if debug:
|
||||
print('DEBUG: Announce was removed for '+actor)
|
||||
postJsonObject['object']['shares']['items'].remove(likeItem)
|
||||
postJsonObject['object']['shares']['items'].remove(announceItem)
|
||||
itemFound=True
|
||||
break
|
||||
if itemFound:
|
||||
if totalItems==1:
|
||||
if debug:
|
||||
print('DEBUG: shares (announcements) was removed from post')
|
||||
postJsonObject['object'].remove(postJsonObject['object']['shares'])
|
||||
del postJsonObject['object']['shares']
|
||||
else:
|
||||
postJsonObject['object']['shares']['totalItems']=len(postJsonObject['shares']['items'])
|
||||
with open(postFilename, 'w') as fp:
|
||||
|
|
27
daemon.py
27
daemon.py
|
@ -673,6 +673,33 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._redirect_headers(actor+'/inbox',cookie)
|
||||
return
|
||||
|
||||
# undo an announce/repeat from the web interface
|
||||
if authorized and '?unrepeat=' in self.path:
|
||||
repeatUrl=self.path.split('?unrepeat=')[1]
|
||||
actor=self.path.split('?unrepeat=')[0]
|
||||
self.postToNickname=getNicknameFromActor(actor)
|
||||
if not self.server.session:
|
||||
self.server.session= \
|
||||
createSession(self.server.domain,self.server.port,self.server.useTor)
|
||||
undoAnnounceActor=self.server.httpPrefix+'://'+self.server.domainFull+'/users/'+self.postToNickname
|
||||
newUndoAnnounce = {
|
||||
'actor': undoAnnounceActor,
|
||||
'type': 'Undo',
|
||||
'cc': [undoAnnounceActor+'/followers'],
|
||||
'to': ['https://www.w3.org/ns/activitystreams#Public'],
|
||||
'object': {
|
||||
'actor': undoAnnounceActor,
|
||||
'cc': [undoAnnounceActor+'/followers'],
|
||||
'object': repeatUrl,
|
||||
'to': ['https://www.w3.org/ns/activitystreams#Public'],
|
||||
'type': 'Announce'
|
||||
}
|
||||
}
|
||||
self._postToOutbox(newUndoAnnounce)
|
||||
self.server.GETbusy=False
|
||||
self._redirect_headers(actor+'/inbox',cookie)
|
||||
return
|
||||
|
||||
# like from the web interface icon
|
||||
if authorized and '?like=' in self.path:
|
||||
likeUrl=self.path.split('?like=')[1]
|
||||
|
|
2
like.py
2
like.py
|
@ -55,7 +55,7 @@ def undoLikesCollectionEntry(postFilename: str,objectUrl: str, actor: str,debug:
|
|||
if totalItems==1:
|
||||
if debug:
|
||||
print('DEBUG: likes was removed from post')
|
||||
postJsonObject['object'].remove(postJsonObject['object']['likes'])
|
||||
del postJsonObject['object']['likes']
|
||||
else:
|
||||
postJsonObject['object']['likes']['totalItems']=len(postJsonObject['likes']['items'])
|
||||
with open(postFilename, 'w') as fp:
|
||||
|
|
|
@ -23,6 +23,7 @@ from posts import parseUserFeed
|
|||
from session import getJson
|
||||
from auth import createPassword
|
||||
from like import likedByPerson
|
||||
from announce import announcedByPerson
|
||||
|
||||
def htmlGetLoginCredentials(loginParams: str,lastLoginTime: int) -> (str,str):
|
||||
"""Receives login credentials via HTTPServer POST
|
||||
|
@ -559,20 +560,27 @@ def individualPostAsHtml(baseDir: str, \
|
|||
footerStr='<span class="'+timeClass+'">'+publishedStr+'</span>\n'
|
||||
|
||||
# don't allow announce/repeat of your own posts
|
||||
announceStr=''
|
||||
likeStr=''
|
||||
if fullDomain+'/users/'+nickname not in postJsonObject['actor']:
|
||||
announceStr= \
|
||||
'<a href="/users/'+nickname+'?repeat='+postJsonObject['object']['id']+'" title="Repeat this post">' \
|
||||
'<img src="/icons/repeat_inactive.png"/></a>'
|
||||
likeIcon='like_inactive.png'
|
||||
likeLink='like'
|
||||
if likedByPerson(postJsonObject,nickname,fullDomain):
|
||||
likeIcon='like.png'
|
||||
likeLink='unlike'
|
||||
likeStr= \
|
||||
'<a href="/users/'+nickname+'?'+likeLink+'='+postJsonObject['object']['id']+'" title="Like this post">' \
|
||||
'<img src="/icons/'+likeIcon+'"/></a>'
|
||||
announceIcon='repeat_inactive.png'
|
||||
announceLink='repeat'
|
||||
announceTitle='Repeat this post'
|
||||
if announcedByPerson(postJsonObject,nickname,fullDomain):
|
||||
announceIcon='repeat.png'
|
||||
announceLink='unrepeat'
|
||||
announceTitle='Undo the repeat this post'
|
||||
announceStr= \
|
||||
'<a href="/users/'+nickname+'?'+announceLink+'='+postJsonObject['object']['id']+'" title="'+announceTitle+'">' \
|
||||
'<img src="/icons/'+announceIcon+'"/></a>'
|
||||
|
||||
likeIcon='like_inactive.png'
|
||||
likeLink='like'
|
||||
likeTitle='Like this post'
|
||||
if likedByPerson(postJsonObject,nickname,fullDomain):
|
||||
likeIcon='like.png'
|
||||
likeLink='unlike'
|
||||
likeTitle='Undo the like of this post'
|
||||
likeStr= \
|
||||
'<a href="/users/'+nickname+'?'+likeLink+'='+postJsonObject['object']['id']+'" title="'+likeTitle+'">' \
|
||||
'<img src="/icons/'+likeIcon+'"/></a>'
|
||||
|
||||
if showIcons:
|
||||
footerStr='<div class="'+containerClassIcons+'">'
|
||||
|
|
Loading…
Reference in New Issue