forked from indymedia/epicyon
prepend to follow/followers files
parent
a65b8bf644
commit
841367fa76
10
follow.py
10
follow.py
|
@ -505,9 +505,13 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \
|
|||
print('Updating followers file: '+followersFilename+' adding '+approveHandle)
|
||||
if os.path.isfile(followersFilename):
|
||||
if approveHandle not in open(followersFilename).read():
|
||||
followersFile=open(followersFilename, "a+")
|
||||
followersFile.write(approveHandle+'\n')
|
||||
followersFile.close()
|
||||
try:
|
||||
with open(followersFilename, 'r+') as followersFile:
|
||||
content = followersFile.read()
|
||||
followersFile.seek(0, 0)
|
||||
followersFile.write(approveHandle+'\n'+content)
|
||||
except Exception as e:
|
||||
print('WARN: Failed to write entry to followers file '+str(e))
|
||||
else:
|
||||
followersFile=open(followersFilename, "w+")
|
||||
followersFile.write(approveHandle+'\n')
|
||||
|
|
16
utils.py
16
utils.py
|
@ -219,11 +219,17 @@ def followPerson(baseDir: str,nickname: str, domain: str, \
|
|||
if debug:
|
||||
print('DEBUG: follow already exists')
|
||||
return True
|
||||
with open(filename, "a") as followfile:
|
||||
followfile.write(followNickname+'@'+followDomain+'\n')
|
||||
if debug:
|
||||
print('DEBUG: follow added')
|
||||
return True
|
||||
# prepend to follow file
|
||||
try:
|
||||
with open(filename, 'r+') as followFile:
|
||||
content = followFile.read()
|
||||
followFile.seek(0, 0)
|
||||
followFile.write(followNickname+'@'+followDomain+'\n'+content)
|
||||
if debug:
|
||||
print('DEBUG: follow added')
|
||||
return True
|
||||
except Exception as e:
|
||||
print('WARN: Failed to write entry to follow file '+filename+' '+str(e))
|
||||
if debug:
|
||||
print('DEBUG: creating new following file')
|
||||
with open(filename, "w") as followfile:
|
||||
|
|
Loading…
Reference in New Issue