From 28a6174e963d4638748607c7bbf20026d5cd49a9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 9 Mar 2021 15:01:35 +0000 Subject: [PATCH] Notification flags on speaker endpoint --- daemon.py | 3 +-- scripts/epicyon-notification | 4 ++-- speaker.py | 28 ++++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/daemon.py b/daemon.py index 5ea50f7ff..60642e4d1 100644 --- a/daemon.py +++ b/daemon.py @@ -4853,8 +4853,7 @@ class PubServer(BaseHTTPRequestHandler): # only receive DMs from accounts you follow followDMsFilename = \ baseDir + '/accounts/' + \ - nickname + '@' + domain + \ - '/.followDMs' + nickname + '@' + domain + '/.followDMs' if onFinalWelcomeScreen: # initial default setting created via # the welcome screen diff --git a/scripts/epicyon-notification b/scripts/epicyon-notification index cdeb716e6..5b4f4ec89 100755 --- a/scripts/epicyon-notification +++ b/scripts/epicyon-notification @@ -209,9 +209,9 @@ function notifications { if [[ "$epicyonLikeFileContent" == *':'* ]]; then epicyonLikeMessage="Epicyon: $epicyonLikeFileContent" fi - "${PROJECT_NAME}-notification" -u "$USERNAME" -s "Epicyon" -m "$epicyonLikeMessage" --sensitive yes + sendNotification "$USERNAME" "Epicyon" "$epicyonLikeMessage" echo "##sent##" > "$epicyonLikeFile" - chown ${PROJECT_NAME}:${PROJECT_NAME} "$epicyonLkeFile" + chown ${PROJECT_NAME}:${PROJECT_NAME} "$epicyonLikeFile" fi fi diff --git a/speaker.py b/speaker.py index b9314e36e..a1c4b5df9 100644 --- a/speaker.py +++ b/speaker.py @@ -266,7 +266,9 @@ def getSpeakerFromServer(baseDir: str, session, def _speakerEndpointJson(displayName: str, summary: str, content: str, imageDescription: str, links: [], gender: str, postId: str, - postDM: bool, postReply: bool) -> {}: + postDM: bool, postReply: bool, + followRequestsExist: bool, + likedBy: str) -> {}: """Returns a json endpoint for the TTS speaker """ speakerJson = { @@ -278,7 +280,9 @@ def _speakerEndpointJson(displayName: str, summary: str, "id": postId, "notify": { "dm": postDM, - "reply": postReply + "reply": postReply, + "followRequests": followRequestsExist, + "likedBy": likedBy } } if gender: @@ -441,11 +445,27 @@ def _postToSpeakerJson(baseDir: str, httpPrefix: str, actor = httpPrefix + '://' + domainFull + '/users/' + nickname postDM = isDM(postJsonObject) postReply = isReply(postJsonObject, actor) + + followRequestsExist = False + accountsDir = baseDir + '/accounts/' + nickname + '@' + domainFull + approveFollowsFilename = accountsDir + '/followrequests.txt' + if os.path.isfile(approveFollowsFilename): + with open(approveFollowsFilename, 'r') as fp: + follows = fp.readlines() + if len(follows) > 0: + followRequestsExist = True + likedBy = '' + likeFilename = accountsDir + '/.newLike' + if os.path.isfile(likeFilename): + with open(likeFilename, 'r') as fp: + likedBy = fp.read() + return _speakerEndpointJson(speakerName, summary, content, imageDescription, detectedLinks, gender, postId, - postDM, postReply) - + postDM, postReply, + followRequestsExist, + likedBy) def updateSpeaker(baseDir: str, httpPrefix: str, nickname: str, domain: str, domainFull: str,