From db8e703c4072ace6845763b9d1ab40d8fb3441cc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 16 Apr 2020 09:55:53 +0100 Subject: [PATCH] Exit loop if not authorized --- daemon.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/daemon.py b/daemon.py index e0e616fb..2a545fae 100644 --- a/daemon.py +++ b/daemon.py @@ -807,7 +807,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.inboxQueue.pop(0) timeDiff = str(int((time.time() - cleardownStartTime) * 1000)) print('Inbox cleardown took ' + timeDiff + ' mS. Removed ' + - str(removals) + ' items.') + str(removals) + ' items. Queue length is now ' + + str(len(self.server.inboxQueue))) def _updateInboxQueue(self, nickname: str, messageJson: {}, messageBytes: str) -> int: @@ -4896,16 +4897,11 @@ class PubServer(BaseHTTPRequestHandler): return 1 return -1 - def _receiveNewPost(self, authorized: bool, postType: str, - path: str) -> int: + def _receiveNewPost(self, postType: str, path: str) -> int: """A new post has been created This creates a thread to send the new post """ pageNumber = 1 - if not authorized: - print('Not receiving new post for ' + path + - ' because not authorized') - return None if '/users/' not in path: print('Not receiving new post for ' + path + @@ -6715,13 +6711,15 @@ class PubServer(BaseHTTPRequestHandler): "newdm", "newreport", "newshare", "newquestion", "editblogpost") for currPostType in postTypes: + if not authorized: + break + if currPostType != 'newshare': postRedirect = self.server.defaultTimeline else: postRedirect = 'shares' - pageNumber = self._receiveNewPost(authorized, currPostType, - self.path) + pageNumber = self._receiveNewPost(currPostType, self.path) if pageNumber: nickname = self.path.split('/users/')[1] if '/' in nickname: