mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-20 00:56:25 +01:00
add adminconfig per dvm
This commit is contained in:
@@ -5,30 +5,49 @@ from nostr_sdk import Keys, EventBuilder, PublicKey
|
||||
|
||||
from utils.database_utils import get_from_sql_table, list_db, delete_from_sql_table, update_sql_table, \
|
||||
get_or_add_user, clean_db
|
||||
from utils.dvmconfig import DVMConfig
|
||||
from utils.nip89_utils import nip89_announce_tasks
|
||||
from utils.nostr_utils import send_event
|
||||
|
||||
class AdminConfig:
|
||||
REBROADCASTNIP89: bool = False
|
||||
WHITELISTUSER: bool = False
|
||||
UNWHITELISTUSER: bool = False
|
||||
BLACKLISTUSER: bool = False
|
||||
DELETEUSER: bool = False
|
||||
LISTDATABASE: bool = False
|
||||
ClEANDB: bool = False
|
||||
USERNPUB: str = ""
|
||||
|
||||
def admin_make_database_updates(config=None, client=None):
|
||||
def admin_make_database_updates(adminconfig: AdminConfig = None, dvmconfig: DVMConfig = None, client=None):
|
||||
# This is called on start of Server, Admin function to manually whitelist/blacklist/add balance/delete users
|
||||
dvmconfig = config
|
||||
db = config.DB
|
||||
if adminconfig is None or dvmconfig is None:
|
||||
return
|
||||
|
||||
rebroadcast_nip89 = False
|
||||
cleandb = False
|
||||
listdatabase = False
|
||||
deleteuser = False
|
||||
whitelistuser = False
|
||||
unwhitelistuser = False
|
||||
blacklistuser = False
|
||||
if not isinstance(adminconfig, AdminConfig):
|
||||
return
|
||||
|
||||
if ((adminconfig.WHITELISTUSER is True or adminconfig.UNWHITELISTUSER is True or adminconfig.BLACKLISTUSER is True or adminconfig.DELETEUSER is True)
|
||||
and adminconfig.USERNPUB == ""):
|
||||
return
|
||||
|
||||
|
||||
# publickey = PublicKey.from_bech32("npub1...").to_hex()
|
||||
# use this if you have the npub
|
||||
publickey = "asd123"
|
||||
#use this if you have hex
|
||||
db = dvmconfig.DB
|
||||
|
||||
rebroadcast_nip89 = adminconfig.REBROADCASTNIP89
|
||||
cleandb = adminconfig.ClEANDB
|
||||
listdatabase = adminconfig.LISTDATABASE
|
||||
deleteuser = adminconfig.DELETEUSER
|
||||
whitelistuser = adminconfig.WHITELISTUSER
|
||||
unwhitelistuser = adminconfig.UNWHITELISTUSER
|
||||
blacklistuser = adminconfig.BLACKLISTUSER
|
||||
|
||||
if adminconfig.USERNPUB != "":
|
||||
if str(adminconfig.USERNPUB).startswith("npub"):
|
||||
publickey = PublicKey.from_bech32(adminconfig.USERNPUB).to_hex()
|
||||
else:
|
||||
publickey = adminconfig.USERNPUB
|
||||
|
||||
|
||||
if whitelistuser:
|
||||
user = get_or_add_user(db, publickey)
|
||||
|
||||
Reference in New Issue
Block a user