diff --git a/malias.py b/malias.py index 27d2a02..6f8bd07 100644 --- a/malias.py +++ b/malias.py @@ -235,6 +235,7 @@ def checklist(alias): def list_alias(): apikey = get_api() + cursor = conn.cursor() mail_server = get_settings('mail_server') req = urllib.request.Request('https://'+mail_server+'/api/v1/get/alias/all') req.add_header('Content-Type', 'application/json') @@ -243,14 +244,21 @@ def list_alias(): remote = current.read().decode('utf-8') remoteData = json.loads(remote) i = 0 - print('\n[b]malias[/b] - All aliases on %s' %(mail_server)) - print('===================================================') + print('\n[b]malias[/b] - All aliases on %s ([b]*[/b] also in local db)' %(mail_server)) + print('==================================================================') for search in remoteData: the_alias = remoteData[i]['address'].ljust(20,' ') - print(the_alias + '\tgoes to\t\t' + remoteData[i]['goto']) + the_goto = remoteData[i]['goto'].ljust(20,' ') + cursor.execute('SELECT count(*) FROM aliases where alias like ? or goto like ?', (remoteData[i]['address'],remoteData[i]['address'],)) + count = cursor.fetchone()[0] + if count >= 1: + print(the_alias + '\tgoes to\t\t' + the_goto + '\t[b]*[/b]') + else: + print(the_alias + '\tgoes to\t\t' + the_goto) i=i+1 - - + print('\n\nTotal number of aliases %s. Fetched from instance [b]%s[/b]' %(str(i),mail_server)) + + def alias_id(alias): apikey = get_api()