2024-07-01 12:56:35 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
sys.path.append(os.environ['AIL_HOME'])
|
|
|
|
##################################
|
|
|
|
# Import Project packages
|
|
|
|
##################################
|
|
|
|
from update.bin.ail_updater import AIL_Updater
|
|
|
|
from lib import ail_users
|
2024-08-27 13:48:11 +00:00
|
|
|
from lib import Investigations
|
2024-07-01 12:56:35 +00:00
|
|
|
from lib.ConfigLoader import ConfigLoader
|
2024-07-09 15:15:27 +00:00
|
|
|
from lib import chats_viewer
|
2024-08-28 14:47:44 +00:00
|
|
|
from lib import Tracker
|
2024-07-01 12:56:35 +00:00
|
|
|
|
|
|
|
class Updater(AIL_Updater):
|
|
|
|
"""default Updater."""
|
|
|
|
|
|
|
|
def __init__(self, version):
|
|
|
|
super(Updater, self).__init__(version)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
config_loader = ConfigLoader()
|
|
|
|
r_serv_db = config_loader.get_db_conn("Kvrocks_DB")
|
|
|
|
config_loader = None
|
|
|
|
date = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
|
|
|
|
|
2024-08-27 13:48:11 +00:00
|
|
|
# ORGS
|
|
|
|
# TODO CREATE DEFAULT ORG
|
|
|
|
|
|
|
|
# USERS
|
|
|
|
print('Updating Users ...')
|
|
|
|
for user_id in ail_users.get_users(): # TODO ORG
|
2024-07-01 12:56:35 +00:00
|
|
|
r_serv_db.hset(f'ail:user:metadata:{user_id}', 'creator', 'admin@admin.test')
|
|
|
|
r_serv_db.hset(f'ail:user:metadata:{user_id}', 'created_at', date)
|
|
|
|
r_serv_db.hset(f'ail:user:metadata:{user_id}', 'last_edit', date)
|
|
|
|
|
2024-08-27 13:48:11 +00:00
|
|
|
# INVESTIGATIONS
|
|
|
|
print('Updating Investigations ...')
|
|
|
|
for inv_uuid in Investigations.get_all_investigations(): # TODO Creator ORG
|
|
|
|
inv = Investigations.Investigation(inv_uuid)
|
|
|
|
inv.set_level(1, None)
|
|
|
|
|
2024-08-28 14:47:44 +00:00
|
|
|
# TODO Trackers
|
|
|
|
|
|
|
|
print('Updating Retro Hunts ...')
|
|
|
|
for retro_hunt_uuid in Tracker.get_all_retro_hunt_tasks(): # TODO Creator ORG
|
|
|
|
retro = Tracker.RetroHunt(retro_hunt_uuid)
|
|
|
|
retro.set_level(1, None)
|
|
|
|
|
2024-07-09 15:15:27 +00:00
|
|
|
chats_viewer.fix_chats_with_messages()
|
|
|
|
|
2024-07-01 12:56:35 +00:00
|
|
|
updater = Updater('v5.7')
|
|
|
|
updater.run_update()
|
|
|
|
|