Browse Source

Refresh newswire after removing or suspending an account

merge-requests/17/merge
Bob Mottram 3 months ago
parent
commit
5ef5174fee
4 changed files with 21 additions and 13 deletions
  1. 1
    1
      daemon.py
  2. 0
    12
      newsdaemon.py
  3. 9
    0
      person.py
  4. 11
    0
      utils.py

+ 1
- 1
daemon.py View File

@@ -218,6 +218,7 @@ from utils import loadJson
218 218
 from utils import saveJson
219 219
 from utils import isSuspended
220 220
 from utils import dangerousMarkup
221
+from utils import refreshNewswire
221 222
 from manualapprove import manualDenyFollowRequest
222 223
 from manualapprove import manualApproveFollowRequest
223 224
 from announce import createAnnounce
@@ -255,7 +256,6 @@ from newswire import rss2Footer
255 256
 from newswire import loadHashtagCategories
256 257
 from newsdaemon import runNewswireWatchdog
257 258
 from newsdaemon import runNewswireDaemon
258
-from newsdaemon import refreshNewswire
259 259
 from filters import isFiltered
260 260
 from filters import addGlobalFilter
261 261
 from filters import removeGlobalFilter

+ 0
- 12
newsdaemon.py View File

@@ -750,15 +750,3 @@ def runNewswireWatchdog(projectVersion: str, httpd) -> None:
750 750
                 newswireOriginal.clone(runNewswireDaemon)
751 751
             httpd.thrNewswireDaemon.start()
752 752
             print('Restarting newswire daemon...')
753
-
754
-
755
-def refreshNewswire(baseDir: str) -> None:
756
-    """Causes the newswire to be updated.
757
-    This creates a file which is then detected by the daemon
758
-    """
759
-    refreshFilename = baseDir + '/accounts/.refresh_newswire'
760
-    if os.path.isfile(refreshFilename):
761
-        return
762
-    refreshFile = open(refreshFilename, 'w+')
763
-    refreshFile.write('\n')
764
-    refreshFile.close()

+ 9
- 0
person.py View File

@@ -40,6 +40,7 @@ from utils import loadJson
40 40
 from utils import saveJson
41 41
 from utils import setConfigParam
42 42
 from utils import getConfigParam
43
+from utils import refreshNewswire
43 44
 
44 45
 
45 46
 def generateRSAKey() -> (str, str):
@@ -915,6 +916,9 @@ def removeAccount(baseDir: str, nickname: str,
915 916
         os.remove(baseDir + '/wfdeactivated/' + handle + '.json')
916 917
     if os.path.isdir(baseDir + '/sharefilesdeactivated/' + nickname):
917 918
         shutil.rmtree(baseDir + '/sharefilesdeactivated/' + nickname)
919
+
920
+    refreshNewswire(baseDir)
921
+
918 922
     return True
919 923
 
920 924
 
@@ -944,6 +948,9 @@ def deactivateAccount(baseDir: str, nickname: str, domain: str) -> bool:
944 948
             os.mkdir(deactivatedSharefilesDir)
945 949
         shutil.move(baseDir + '/sharefiles/' + nickname,
946 950
                     deactivatedSharefilesDir + '/' + nickname)
951
+
952
+    refreshNewswire(baseDir)
953
+
947 954
     return os.path.isdir(deactivatedDir + '/' + nickname + '@' + domain)
948 955
 
949 956
 
@@ -970,6 +977,8 @@ def activateAccount(baseDir: str, nickname: str, domain: str) -> None:
970 977
             shutil.move(deactivatedSharefilesDir + '/' + nickname,
971 978
                         baseDir + '/sharefiles/' + nickname)
972 979
 
980
+    refreshNewswire(baseDir)
981
+
973 982
 
974 983
 def isPersonSnoozed(baseDir: str, nickname: str, domain: str,
975 984
                     snoozeActor: str) -> bool:

+ 11
- 0
utils.py View File

@@ -26,6 +26,17 @@ invalidCharacters = (
26 26
 )
27 27
 
28 28
 
29
+def refreshNewswire(baseDir: str):
30
+    """Causes the newswire to be updates after a change to user accounts
31
+    """
32
+    refreshNewswireFilename = baseDir + '/accounts/.refresh_newswire'
33
+    if os.path.isfile(refreshNewswireFilename):
34
+        return
35
+    refreshFile = open(refreshNewswireFilename, 'w+')
36
+    refreshFile.write('\n')
37
+    refreshFile.close()
38
+
39
+
29 40
 def getSHA256(msg: str):
30 41
     """Returns a SHA256 hash of the given string
31 42
     """

Loading…
Cancel
Save