From 4beddb15844e5dc7df05a1e3557be3f165d2713f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 20 Oct 2019 11:25:38 +0100 Subject: [PATCH] Create an index of received posts --- inbox.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/inbox.py b/inbox.py index 4b683382b..33db70a5c 100644 --- a/inbox.py +++ b/inbox.py @@ -1505,6 +1505,16 @@ def inboxUpdateCalendar(baseDir: str,handle: str,postJsonObject: {}) -> None: calendarNotificationFile.write('/calendar?year='+str(eventYear)+'?month='+str(eventMonthNumber)+'?day='+str(eventDayOfMonth)) calendarNotificationFile.close() +def inboxUpdateIndex(baseDir: str,handle: str,destinationFilename: str) -> None: + """Updates the index of received posts + The new entry is added to the top of the file + """ + indexFilename=baseDir+'/accounts/'+handle+'/inbox.index' + with open(indexFilename, 'r+') as indexFile: + content = indexFile.read() + indexFile.seek(0, 0) + indexFile.write(destinationFilename+'\n'+content) + def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \ baseDir: str,httpPrefix: str,sendThreads: [], \ postLog: [],cachedWebfingers: {},personCache: {}, \ @@ -1640,6 +1650,8 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \ tries+=1 if postSavedToFile: + inboxUpdateIndex(baseDir,handle,destinationFilename) + inboxUpdateCalendar(baseDir,handle,postJsonObject) if not unitTest: