From 33077ab8df5942214c93b4d23c4f27a6e5428d62 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 2 Jul 2019 15:02:58 +0100 Subject: [PATCH] Like a post --- announce.py | 4 ++-- like.py | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/announce.py b/announce.py index 9601d5cb5..708b7adb3 100644 --- a/announce.py +++ b/announce.py @@ -67,8 +67,8 @@ def announcePublic(baseDir: str,federationList: [],username: str, domain: str, p ccUrl = prefix + '://'+fromDomain+'/users/'+username+'/followers' return createAnnounce(baseDir,username, domain, port,toUrl, ccUrl, https, objectUrl, saveToFile) -def repeatMessage(baseDir: str,federationList: [],username: str, domain: str, port: int, https: bool, announceUsername: str, announceDomain: str, announcePort: int, announceStatusNumber: int, announceHttps: bool, saveToFile: bool) -> {}: - """Repeats a given status message +def repeatPost(baseDir: str,federationList: [],username: str, domain: str, port: int, https: bool, announceUsername: str, announceDomain: str, announcePort: int, announceStatusNumber: int, announceHttps: bool, saveToFile: bool) -> {}: + """Repeats a given status post """ prefix='https' if not announceHttps: diff --git a/like.py b/like.py index a63c5af31..625acb848 100644 --- a/like.py +++ b/like.py @@ -10,7 +10,7 @@ import json import commentjson from utils import urlPermitted -def like(baseDir: str,federationList: [],username: str, domain: str, port: int,toUrl: str, ccUrl: str, https: bool,objectUrl: str, saveToFile: bool) -> {}: +def like(baseDir: str,federationList: [],username: str,domain: str,port: int,toUrl: str,ccUrl: str,https: bool,objectUrl: str,saveToFile: bool) -> {}: """Creates a like Typically toUrl will be a followers collection and ccUrl might be a specific person whose post was liked @@ -42,3 +42,18 @@ def like(baseDir: str,federationList: [],username: str, domain: str, port: int,t domain=domain.split(':')[0] # TODO update likes collection return newLike + +def likePost(baseDir: str,federationList: [],username: str, domain: str, port: int, https: bool, likeUsername: str, likeDomain: str, likePort: int, likeStatusNumber: int, likeHttps: bool,saveToFile: bool) -> {}: + """Likes a given status post + """ + prefix='https' + if not likeHttps: + prefix='http' + + likeDomain=likeDomain + if likePort!=80 and likePort!=443: + likeDomain=likeDomain+':'+str(likePort) + + objectUrl = prefix + '://'+likeDomain+'/users/'+likeUsername+'/statuses/'+str(likeStatusNumber) + + return like(baseDir,federationList,username,domain,port,toUrl,ccUrl,https,objectUrl,saveToFile)