mirror of https://gitlab.com/bashrc2/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)
|
print('Updating followers file: '+followersFilename+' adding '+approveHandle)
|
||||||
if os.path.isfile(followersFilename):
|
if os.path.isfile(followersFilename):
|
||||||
if approveHandle not in open(followersFilename).read():
|
if approveHandle not in open(followersFilename).read():
|
||||||
followersFile=open(followersFilename, "a+")
|
try:
|
||||||
followersFile.write(approveHandle+'\n')
|
with open(followersFilename, 'r+') as followersFile:
|
||||||
followersFile.close()
|
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:
|
else:
|
||||||
followersFile=open(followersFilename, "w+")
|
followersFile=open(followersFilename, "w+")
|
||||||
followersFile.write(approveHandle+'\n')
|
followersFile.write(approveHandle+'\n')
|
||||||
|
|
16
utils.py
16
utils.py
|
@ -219,11 +219,17 @@ def followPerson(baseDir: str,nickname: str, domain: str, \
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: follow already exists')
|
print('DEBUG: follow already exists')
|
||||||
return True
|
return True
|
||||||
with open(filename, "a") as followfile:
|
# prepend to follow file
|
||||||
followfile.write(followNickname+'@'+followDomain+'\n')
|
try:
|
||||||
if debug:
|
with open(filename, 'r+') as followFile:
|
||||||
print('DEBUG: follow added')
|
content = followFile.read()
|
||||||
return True
|
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:
|
if debug:
|
||||||
print('DEBUG: creating new following file')
|
print('DEBUG: creating new following file')
|
||||||
with open(filename, "w") as followfile:
|
with open(filename, "w") as followfile:
|
||||||
|
|
Loading…
Reference in New Issue