forked from indymedia/epicyon
Check that an account can receive calendar events from the actor
parent
5a7a235cbb
commit
ebd681d11a
|
@ -50,6 +50,12 @@ def receiveCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(calendarFilename):
|
if os.path.isfile(calendarFilename):
|
||||||
with open(calendarFilename, 'r') as calendarFile:
|
with open(calendarFilename, 'r') as calendarFile:
|
||||||
followingHandles = calendarFile.read()
|
followingHandles = calendarFile.read()
|
||||||
|
else:
|
||||||
|
# create a new calendar file from the following file
|
||||||
|
with open(followingFilename, 'r') as followingFile:
|
||||||
|
followingHandles = followingFile.read()
|
||||||
|
with open(calendarFilename, 'w') as fp:
|
||||||
|
fp.write(followingHandles)
|
||||||
|
|
||||||
# already in the calendar file?
|
# already in the calendar file?
|
||||||
if handle + '\n' in followingHandles:
|
if handle + '\n' in followingHandles:
|
||||||
|
|
12
inbox.py
12
inbox.py
|
@ -62,6 +62,7 @@ from question import questionUpdateVotes
|
||||||
from media import replaceYouTube
|
from media import replaceYouTube
|
||||||
from git import isGitPatch
|
from git import isGitPatch
|
||||||
from git import receiveGitPatch
|
from git import receiveGitPatch
|
||||||
|
from calendar import receivingCalendarEvents
|
||||||
|
|
||||||
|
|
||||||
def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None:
|
def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None:
|
||||||
|
@ -1844,6 +1845,8 @@ def inboxUpdateCalendar(baseDir: str, handle: str, postJsonObject: {}) -> None:
|
||||||
and if so saves the post id to a file in the calendar directory
|
and if so saves the post id to a file in the calendar directory
|
||||||
for the account
|
for the account
|
||||||
"""
|
"""
|
||||||
|
if not postJsonObject.get('actor'):
|
||||||
|
return
|
||||||
if not postJsonObject.get('object'):
|
if not postJsonObject.get('object'):
|
||||||
return
|
return
|
||||||
if not isinstance(postJsonObject['object'], dict):
|
if not isinstance(postJsonObject['object'], dict):
|
||||||
|
@ -1857,6 +1860,15 @@ def inboxUpdateCalendar(baseDir: str, handle: str, postJsonObject: {}) -> None:
|
||||||
if not os.path.isdir(calendarPath):
|
if not os.path.isdir(calendarPath):
|
||||||
os.mkdir(calendarPath)
|
os.mkdir(calendarPath)
|
||||||
|
|
||||||
|
actor = postJsonObject['actor']
|
||||||
|
actorNickname = getNicknameFromActor(actor)
|
||||||
|
actorDomain, actorPort = getDomainFromActor(actor)
|
||||||
|
if not receivingCalendarEvents(baseDir,
|
||||||
|
handle.split('@')[0],
|
||||||
|
handle.split('@')[1],
|
||||||
|
actorNickname,
|
||||||
|
actorDomain):
|
||||||
|
return
|
||||||
for tagDict in postJsonObject['object']['tag']:
|
for tagDict in postJsonObject['object']['tag']:
|
||||||
if tagDict['type'] != 'Event':
|
if tagDict['type'] != 'Event':
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue