Refind check for existing alias on server and in db

This commit is contained in:
rune 2023-11-09 12:02:11 +01:00
parent 967390ddfa
commit 1c7dd7e44d

View File

@ -29,7 +29,7 @@ database = filepath.joinpath('malias.db')
logfile = filepath.joinpath('malias.log') logfile = filepath.joinpath('malias.log')
Path(filepath).mkdir(parents=True, exist_ok=True) Path(filepath).mkdir(parents=True, exist_ok=True)
logging.basicConfig(filename=logfile,level=logging.INFO,format='%(message)s') logging.basicConfig(filename=logfile,level=logging.INFO,format='%(message)s')
app_version = '0.3.1' app_version = '0.3.2'
def get_latest_release(): def get_latest_release():
@ -116,7 +116,6 @@ def get_settings(kind):
def get_api(): def get_api():
latest_release = get_latest_release()
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('SELECT api FROM apikey') cursor.execute('SELECT api FROM apikey')
apikey = cursor.fetchone()[0] apikey = cursor.fetchone()[0]
@ -299,11 +298,11 @@ def checklist(alias):
remoteData = json.loads(remote) remoteData = json.loads(remote)
i = 0 i = 0
for search in remoteData: for search in remoteData:
if alias in remoteData[i]['address'] or alias in remoteData[i]['goto']: if alias == remoteData[i]['address'] or alias == remoteData[i]['goto']:
alias_exist = True alias_exist = True
i=i+1 i=i+1
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('SELECT count(*) FROM aliases where alias like ? or goto like ?', (alias,alias,)) cursor.execute('SELECT count(*) FROM aliases where alias == ? or goto == ?', (alias,alias,))
count = cursor.fetchone()[0] count = cursor.fetchone()[0]
if count >= 1 : if count >= 1 :
alias_exist = True alias_exist = True