mirror of https://gitlab.com/bashrc2/epicyon
parent
cd008c3013
commit
550a993711
3
auth.py
3
auth.py
|
|
@ -173,7 +173,8 @@ def storeBasicCredentials(baseDir: str, nickname: str, password: str) -> bool:
|
||||||
os.rename(passwordFile + '.new', passwordFile)
|
os.rename(passwordFile + '.new', passwordFile)
|
||||||
else:
|
else:
|
||||||
# append to password file
|
# append to password file
|
||||||
storeValue(passwordFile, storeStr, 'append')
|
with open(passwordFile, 'a+') as passfile:
|
||||||
|
passfile.write(storeStr + '\n')
|
||||||
else:
|
else:
|
||||||
storeValue(passwordFile, storeStr, 'write')
|
storeValue(passwordFile, storeStr, 'write')
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
14
blocking.py
14
blocking.py
|
|
@ -40,7 +40,10 @@ def addGlobalBlock(baseDir: str,
|
||||||
if blockHandle in open(blockingFilename).read():
|
if blockHandle in open(blockingFilename).read():
|
||||||
return False
|
return False
|
||||||
# block an account handle or domain
|
# block an account handle or domain
|
||||||
storeValue(blockingFilename, blockHandle, 'append')
|
blockFile = open(blockingFilename, "a+")
|
||||||
|
if blockFile:
|
||||||
|
blockFile.write(blockHandle + '\n')
|
||||||
|
blockFile.close()
|
||||||
else:
|
else:
|
||||||
blockHashtag = blockNickname
|
blockHashtag = blockNickname
|
||||||
# is the hashtag already blocked?
|
# is the hashtag already blocked?
|
||||||
|
|
@ -48,7 +51,10 @@ def addGlobalBlock(baseDir: str,
|
||||||
if blockHashtag + '\n' in open(blockingFilename).read():
|
if blockHashtag + '\n' in open(blockingFilename).read():
|
||||||
return False
|
return False
|
||||||
# block a hashtag
|
# block a hashtag
|
||||||
storeValue(blockingFilename, blockHashtag, 'append')
|
blockFile = open(blockingFilename, "a+")
|
||||||
|
if blockFile:
|
||||||
|
blockFile.write(blockHashtag + '\n')
|
||||||
|
blockFile.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -64,7 +70,9 @@ def addBlock(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(blockingFilename):
|
if os.path.isfile(blockingFilename):
|
||||||
if blockHandle in open(blockingFilename).read():
|
if blockHandle in open(blockingFilename).read():
|
||||||
return False
|
return False
|
||||||
storeValue(blockingFilename, blockHandle, 'append')
|
blockFile = open(blockingFilename, "a+")
|
||||||
|
blockFile.write(blockHandle + '\n')
|
||||||
|
blockFile.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -432,7 +432,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.maxReplies,
|
self.server.maxReplies,
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
# record the vote
|
# record the vote
|
||||||
storeValue(votesFilename, messageId, 'append')
|
votesFile = open(votesFilename, 'a+')
|
||||||
|
if votesFile:
|
||||||
|
votesFile.write(messageId + '\n')
|
||||||
|
votesFile.close()
|
||||||
|
|
||||||
# ensure that the cached post is removed if it exists,
|
# ensure that the cached post is removed if it exists,
|
||||||
# so that it then will be recreated
|
# so that it then will be recreated
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ __email__ = "bob@freedombone.net"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from storage import storeValue
|
|
||||||
|
|
||||||
|
|
||||||
def addFilter(baseDir: str, nickname: str, domain: str, words: str) -> bool:
|
def addFilter(baseDir: str, nickname: str, domain: str, words: str) -> bool:
|
||||||
|
|
@ -18,7 +17,9 @@ def addFilter(baseDir: str, nickname: str, domain: str, words: str) -> bool:
|
||||||
if os.path.isfile(filtersFilename):
|
if os.path.isfile(filtersFilename):
|
||||||
if words in open(filtersFilename).read():
|
if words in open(filtersFilename).read():
|
||||||
return False
|
return False
|
||||||
storeValue(filtersFilename, words, 'append')
|
filtersFile = open(filtersFilename, "a+")
|
||||||
|
filtersFile.write(words + '\n')
|
||||||
|
filtersFile.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -34,7 +35,9 @@ def addGlobalFilter(baseDir: str, words: str) -> bool:
|
||||||
if os.path.isfile(filtersFilename):
|
if os.path.isfile(filtersFilename):
|
||||||
if words in open(filtersFilename).read():
|
if words in open(filtersFilename).read():
|
||||||
return False
|
return False
|
||||||
storeValue(filtersFilename, words, 'append')
|
filtersFile = open(filtersFilename, "a+")
|
||||||
|
filtersFile.write(words + '\n')
|
||||||
|
filtersFile.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,8 @@ def unfollowAccount(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(unfollowedFilename):
|
if os.path.isfile(unfollowedFilename):
|
||||||
if handleToUnfollowLower not in \
|
if handleToUnfollowLower not in \
|
||||||
open(unfollowedFilename).read().lower():
|
open(unfollowedFilename).read().lower():
|
||||||
storeValue(unfollowedFilename, handleToUnfollow, 'append')
|
with open(unfollowedFilename, "a+") as f:
|
||||||
|
f.write(handleToUnfollow + '\n')
|
||||||
else:
|
else:
|
||||||
storeValue(unfollowedFilename, handleToUnfollow, 'write')
|
storeValue(unfollowedFilename, handleToUnfollow, 'write')
|
||||||
|
|
||||||
|
|
@ -598,7 +599,8 @@ def _storeFollowRequest(baseDir: str,
|
||||||
|
|
||||||
if os.path.isfile(approveFollowsFilename):
|
if os.path.isfile(approveFollowsFilename):
|
||||||
if approveHandle not in open(approveFollowsFilename).read():
|
if approveHandle not in open(approveFollowsFilename).read():
|
||||||
storeValue(approveFollowsFilename, approveHandleStored, 'append')
|
with open(approveFollowsFilename, 'a+') as fp:
|
||||||
|
fp.write(approveHandleStored + '\n')
|
||||||
else:
|
else:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: ' + approveHandleStored +
|
print('DEBUG: ' + approveHandleStored +
|
||||||
|
|
|
||||||
26
happening.py
26
happening.py
|
|
@ -118,8 +118,11 @@ def saveEventPost(baseDir: str, handle: str, postId: str,
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# append the post Id to the file for the calendar month
|
# append the post Id to the file for the calendar month
|
||||||
if not storeValue(calendarFilename, postId, 'append'):
|
calendarFile = open(calendarFilename, 'a+')
|
||||||
|
if not calendarFile:
|
||||||
return False
|
return False
|
||||||
|
calendarFile.write(postId + '\n')
|
||||||
|
calendarFile.close()
|
||||||
|
|
||||||
# create a file which will trigger a notification that
|
# create a file which will trigger a notification that
|
||||||
# a new event has been added
|
# a new event has been added
|
||||||
|
|
@ -242,10 +245,9 @@ def getTodaysEvents(baseDir: str, nickname: str, domain: str,
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
calendarFile = open(calendarFilename, 'w+')
|
calendarFile = open(calendarFilename, 'w+')
|
||||||
if calendarFile:
|
for postId in calendarPostIds:
|
||||||
for postId in calendarPostIds:
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.close()
|
||||||
calendarFile.close()
|
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
|
@ -360,10 +362,9 @@ def getThisWeeksEvents(baseDir: str, nickname: str, domain: str) -> {}:
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
calendarFile = open(calendarFilename, 'w+')
|
calendarFile = open(calendarFilename, 'w+')
|
||||||
if calendarFile:
|
for postId in calendarPostIds:
|
||||||
for postId in calendarPostIds:
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.close()
|
||||||
calendarFile.close()
|
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
|
@ -426,10 +427,9 @@ def getCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
calendarFile = open(calendarFilename, 'w+')
|
calendarFile = open(calendarFilename, 'w+')
|
||||||
if calendarFile:
|
for postId in calendarPostIds:
|
||||||
for postId in calendarPostIds:
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.close()
|
||||||
calendarFile.close()
|
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
|
|
||||||
10
inbox.py
10
inbox.py
|
|
@ -2816,7 +2816,10 @@ def _checkJsonSignature(baseDir: str, queueJson: {}) -> (bool, bool):
|
||||||
alreadyUnknown = True
|
alreadyUnknown = True
|
||||||
|
|
||||||
if not alreadyUnknown:
|
if not alreadyUnknown:
|
||||||
storeValue(unknownContextsFile, unknownContext, 'append')
|
unknownFile = open(unknownContextsFile, "a+")
|
||||||
|
if unknownFile:
|
||||||
|
unknownFile.write(unknownContext + '\n')
|
||||||
|
unknownFile.close()
|
||||||
else:
|
else:
|
||||||
print('Unrecognized jsonld signature type: ' +
|
print('Unrecognized jsonld signature type: ' +
|
||||||
jwebsigType)
|
jwebsigType)
|
||||||
|
|
@ -2831,7 +2834,10 @@ def _checkJsonSignature(baseDir: str, queueJson: {}) -> (bool, bool):
|
||||||
alreadyUnknown = True
|
alreadyUnknown = True
|
||||||
|
|
||||||
if not alreadyUnknown:
|
if not alreadyUnknown:
|
||||||
storeValue(unknownSignaturesFile, jwebsigType, 'append')
|
unknownFile = open(unknownSignaturesFile, "a+")
|
||||||
|
if unknownFile:
|
||||||
|
unknownFile.write(jwebsigType + '\n')
|
||||||
|
unknownFile.close()
|
||||||
return hasJsonSignature, jwebsigType
|
return hasJsonSignature, jwebsigType
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ from follow import followedAccountAccepts
|
||||||
from follow import followedAccountRejects
|
from follow import followedAccountRejects
|
||||||
from follow import removeFromFollowRequests
|
from follow import removeFromFollowRequests
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from storage import storeValue
|
|
||||||
|
|
||||||
|
|
||||||
def manualDenyFollowRequest(session, baseDir: str,
|
def manualDenyFollowRequest(session, baseDir: str,
|
||||||
|
|
@ -42,7 +41,9 @@ def manualDenyFollowRequest(session, baseDir: str,
|
||||||
removeFromFollowRequests(baseDir, nickname, domain, denyHandle, debug)
|
removeFromFollowRequests(baseDir, nickname, domain, denyHandle, debug)
|
||||||
|
|
||||||
# Store rejected follows
|
# Store rejected follows
|
||||||
storeValue(rejectedFollowsFilename, denyHandle, 'append')
|
rejectsFile = open(rejectedFollowsFilename, "a+")
|
||||||
|
rejectsFile.write(denyHandle + '\n')
|
||||||
|
rejectsFile.close()
|
||||||
|
|
||||||
denyNickname = denyHandle.split('@')[0]
|
denyNickname = denyHandle.split('@')[0]
|
||||||
denyDomain = \
|
denyDomain = \
|
||||||
|
|
@ -69,9 +70,13 @@ def _approveFollowerHandle(accountDir: str, approveHandle: str) -> None:
|
||||||
approvedFilename = accountDir + '/approved.txt'
|
approvedFilename = accountDir + '/approved.txt'
|
||||||
if os.path.isfile(approvedFilename):
|
if os.path.isfile(approvedFilename):
|
||||||
if approveHandle not in open(approvedFilename).read():
|
if approveHandle not in open(approvedFilename).read():
|
||||||
storeValue(approvedFilename, approveHandle, 'append')
|
approvedFile = open(approvedFilename, "a+")
|
||||||
|
approvedFile.write(approveHandle + '\n')
|
||||||
|
approvedFile.close()
|
||||||
else:
|
else:
|
||||||
storeValue(approvedFilename, approveHandle, 'write')
|
approvedFile = open(approvedFilename, "w+")
|
||||||
|
approvedFile.write(approveHandle + '\n')
|
||||||
|
approvedFile.close()
|
||||||
|
|
||||||
|
|
||||||
def manualApproveFollowRequest(session, baseDir: str,
|
def manualApproveFollowRequest(session, baseDir: str,
|
||||||
|
|
@ -196,7 +201,9 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
else:
|
else:
|
||||||
print('Manual follow accept: first follower accepted for ' +
|
print('Manual follow accept: first follower accepted for ' +
|
||||||
handle + ' is ' + approveHandleFull)
|
handle + ' is ' + approveHandleFull)
|
||||||
storeValue(followersFilename, approveHandleFull, 'write')
|
followersFile = open(followersFilename, "w+")
|
||||||
|
followersFile.write(approveHandleFull + '\n')
|
||||||
|
followersFile.close()
|
||||||
|
|
||||||
# only update the follow requests file if the follow is confirmed to be
|
# only update the follow requests file if the follow is confirmed to be
|
||||||
# in followers.txt
|
# in followers.txt
|
||||||
|
|
|
||||||
|
|
@ -1144,8 +1144,11 @@ def personSnooze(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(snoozedFilename):
|
if os.path.isfile(snoozedFilename):
|
||||||
if snoozeActor + ' ' in open(snoozedFilename).read():
|
if snoozeActor + ' ' in open(snoozedFilename).read():
|
||||||
return
|
return
|
||||||
storeStr = snoozeActor + ' ' + str(int(time.time()))
|
snoozedFile = open(snoozedFilename, "a+")
|
||||||
storeValue(snoozedFilename, storeStr, 'append')
|
if snoozedFile:
|
||||||
|
snoozedFile.write(snoozeActor + ' ' +
|
||||||
|
str(int(time.time())) + '\n')
|
||||||
|
snoozedFile.close()
|
||||||
|
|
||||||
|
|
||||||
def personUnsnooze(baseDir: str, nickname: str, domain: str,
|
def personUnsnooze(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
|
||||||
13
threads.py
13
threads.py
|
|
@ -10,7 +10,6 @@ import threading
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
from storage import storeValue
|
|
||||||
|
|
||||||
|
|
||||||
class threadWithTrace(threading.Thread):
|
class threadWithTrace(threading.Thread):
|
||||||
|
|
@ -140,8 +139,10 @@ def removeDormantThreads(baseDir: str, threadsList: [], debug: bool,
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
sendLogFilename = baseDir + '/send.csv'
|
sendLogFilename = baseDir + '/send.csv'
|
||||||
storeStr = \
|
try:
|
||||||
currTime.strftime("%Y-%m-%dT%H:%M:%SZ") + \
|
with open(sendLogFilename, "a+") as logFile:
|
||||||
',' + str(noOfActiveThreads) + \
|
logFile.write(currTime.strftime("%Y-%m-%dT%H:%M:%SZ") +
|
||||||
',' + str(len(threadsList))
|
',' + str(noOfActiveThreads) +
|
||||||
storeValue(sendLogFilename, storeStr, 'append')
|
',' + str(len(threadsList)) + '\n')
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
|
||||||
3
utils.py
3
utils.py
|
|
@ -951,7 +951,8 @@ def _setDefaultPetName(baseDir: str, nickname: str, domain: str,
|
||||||
# petname already exists
|
# petname already exists
|
||||||
return
|
return
|
||||||
# petname doesn't already exist
|
# petname doesn't already exist
|
||||||
storeValue(petnamesFilename, petnameLookupEntry, 'append')
|
with open(petnamesFilename, 'a+') as petnamesFile:
|
||||||
|
petnamesFile.write(petnameLookupEntry)
|
||||||
|
|
||||||
|
|
||||||
def followPerson(baseDir: str, nickname: str, domain: str,
|
def followPerson(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue