forked from indymedia/epicyon
Update post cache when receiving question updates
parent
6c10a30069
commit
91058ea30f
|
@ -230,6 +230,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
getCachedPostFilename(self.server.baseDir, \
|
getCachedPostFilename(self.server.baseDir, \
|
||||||
nickname, \
|
nickname, \
|
||||||
self.server.domain,messageJson)
|
self.server.domain,messageJson)
|
||||||
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
|
|
19
inbox.py
19
inbox.py
|
@ -12,6 +12,8 @@ import datetime
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
from utils import getCachedPostFilename
|
||||||
|
from utils import removePostFromCache
|
||||||
from utils import urlPermitted
|
from utils import urlPermitted
|
||||||
from utils import createInboxQueueDir
|
from utils import createInboxQueueDir
|
||||||
from utils import getStatusNumber
|
from utils import getStatusNumber
|
||||||
|
@ -741,7 +743,7 @@ def receiveUpdate(session,baseDir: str, \
|
||||||
httpPrefix: str,domain :str,port: int, \
|
httpPrefix: str,domain :str,port: int, \
|
||||||
sendThreads: [],postLog: [],cachedWebfingers: {}, \
|
sendThreads: [],postLog: [],cachedWebfingers: {}, \
|
||||||
personCache: {},messageJson: {},federationList: [], \
|
personCache: {},messageJson: {},federationList: [], \
|
||||||
debug : bool) -> bool:
|
nickname: str,debug : bool) -> bool:
|
||||||
"""Receives an Update activity within the POST section of HTTPServer
|
"""Receives an Update activity within the POST section of HTTPServer
|
||||||
"""
|
"""
|
||||||
if messageJson['type']!='Update':
|
if messageJson['type']!='Update':
|
||||||
|
@ -769,6 +771,20 @@ def receiveUpdate(session,baseDir: str, \
|
||||||
print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type'])
|
print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type'])
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if messageJson['object']['type']=='Question':
|
||||||
|
# ensure that the cached post is removed if it exists, so
|
||||||
|
# that it then will be recreated
|
||||||
|
cachedPostFilename= \
|
||||||
|
getCachedPostFilename(baseDir,nickname,domain,messageJson)
|
||||||
|
if cachedPostFilename:
|
||||||
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
os.remove(cachedPostFilename)
|
||||||
|
# remove from memory cache
|
||||||
|
removePostFromCache(messageJson,self.server.recentPostsCache)
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: Question update was received')
|
||||||
|
return True
|
||||||
|
|
||||||
if messageJson['object']['type']=='Person' or \
|
if messageJson['object']['type']=='Person' or \
|
||||||
messageJson['object']['type']=='Application' or \
|
messageJson['object']['type']=='Application' or \
|
||||||
messageJson['object']['type']=='Group' or \
|
messageJson['object']['type']=='Group' or \
|
||||||
|
@ -2121,6 +2137,7 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
|
||||||
personCache, \
|
personCache, \
|
||||||
queueJson['post'], \
|
queueJson['post'], \
|
||||||
federationList, \
|
federationList, \
|
||||||
|
queueJson['postNickname'], \
|
||||||
debug):
|
debug):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Update accepted from '+keyId)
|
print('DEBUG: Update accepted from '+keyId)
|
||||||
|
|
Loading…
Reference in New Issue