mirror of https://gitlab.com/bashrc2/epicyon
Comments
parent
bbad9879c1
commit
8735567751
16
inbox.py
16
inbox.py
|
@ -1970,6 +1970,8 @@ def inboxUpdateCalendar(baseDir: str, handle: str, postJsonObject: {}) -> None:
|
|||
handleNickname, handleDomain,
|
||||
actorNickname, actorDomain):
|
||||
return
|
||||
|
||||
# look for events within the tags list
|
||||
for tagDict in postJsonObject['object']['tag']:
|
||||
if not tagDict.get('type'):
|
||||
continue
|
||||
|
@ -1977,26 +1979,38 @@ def inboxUpdateCalendar(baseDir: str, handle: str, postJsonObject: {}) -> None:
|
|||
continue
|
||||
if not tagDict.get('startTime'):
|
||||
continue
|
||||
# get the year and month from the event
|
||||
|
||||
# get the year, month and day from the event
|
||||
eventTime = datetime.datetime.strptime(tagDict['startTime'],
|
||||
"%Y-%m-%dT%H:%M:%S%z")
|
||||
eventYear = int(eventTime.strftime("%Y"))
|
||||
eventMonthNumber = int(eventTime.strftime("%m"))
|
||||
eventDayOfMonth = int(eventTime.strftime("%d"))
|
||||
|
||||
# create a directory for the calendar year
|
||||
if not os.path.isdir(calendarPath + '/' + str(eventYear)):
|
||||
os.mkdir(calendarPath + '/' + str(eventYear))
|
||||
|
||||
# calendar month file containing event post Ids
|
||||
calendarFilename = calendarPath + '/' + str(eventYear) + \
|
||||
'/' + str(eventMonthNumber) + '.txt'
|
||||
postId = \
|
||||
postJsonObject['id'].replace('/activity', '').replace('/', '#')
|
||||
|
||||
# Does this event post already exist within the calendar month?
|
||||
if os.path.isfile(calendarFilename):
|
||||
if postId in open(calendarFilename).read():
|
||||
# Event post already exists
|
||||
return
|
||||
|
||||
# append the post Id to the file for the calendar month
|
||||
calendarFile = open(calendarFilename, 'a+')
|
||||
if calendarFile:
|
||||
calendarFile.write(postId + '\n')
|
||||
calendarFile.close()
|
||||
|
||||
# create a file which will trigger a notification that
|
||||
# a new event has been added
|
||||
calendarNotificationFilename = \
|
||||
baseDir + '/accounts/' + handle + '/.newCalendar'
|
||||
calendarNotificationFile = \
|
||||
|
|
Loading…
Reference in New Issue