mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-04-11 21:29:25 +02:00
make deletenip89 callable in admin config
This commit is contained in:
parent
fa2b9d266c
commit
dce7cab5e6
@ -15,6 +15,7 @@ from utils.nostr_utils import send_event, update_profile
|
||||
class AdminConfig:
|
||||
REBROADCAST_NIP89: bool = False
|
||||
UPDATE_PROFILE: bool = False
|
||||
DELETE_NIP89: bool = False
|
||||
WHITELISTUSER: bool = False
|
||||
UNWHITELISTUSER: bool = False
|
||||
BLACKLISTUSER: bool = False
|
||||
@ -25,6 +26,9 @@ class AdminConfig:
|
||||
USERNPUB: str = ""
|
||||
LUD16: str = ""
|
||||
|
||||
EVENTID: str = ""
|
||||
PRIVKEY: str = ""
|
||||
|
||||
|
||||
def admin_make_database_updates(adminconfig: AdminConfig = None, dvmconfig: DVMConfig = None, client: Client = None):
|
||||
# This is called on start of Server, Admin function to manually whitelist/blacklist/add balance/delete users
|
||||
@ -42,6 +46,9 @@ def admin_make_database_updates(adminconfig: AdminConfig = None, dvmconfig: DVMC
|
||||
if adminconfig.UPDATE_PROFILE and (dvmconfig.NIP89 is None):
|
||||
return
|
||||
|
||||
if adminconfig.DELETE_NIP89 and (adminconfig.EVENTID == "" or adminconfig.EVENTID == ""):
|
||||
return
|
||||
|
||||
db = dvmconfig.DB
|
||||
|
||||
if str(adminconfig.USERNPUB).startswith("npub"):
|
||||
@ -75,12 +82,11 @@ def admin_make_database_updates(adminconfig: AdminConfig = None, dvmconfig: DVMC
|
||||
if adminconfig.REBROADCAST_NIP89:
|
||||
nip89_announce_tasks(dvmconfig, client=client)
|
||||
|
||||
# TODO make this callable
|
||||
delete_previous_announcement = False
|
||||
if delete_previous_announcement:
|
||||
eventid = "" #Id of Event to delete
|
||||
keys = Keys.from_sk_str("") # Private key from sender of Event (e.g. the key of an nip89 announcement you want to delete)
|
||||
fetch_nip89_paramters_for_deletion(keys, eventid, client, dvmconfig)
|
||||
if adminconfig.DELETE_NIP89:
|
||||
event_id = adminconfig.EVENTID
|
||||
keys = Keys.from_sk_str(
|
||||
adminconfig.PRIVKEY) # Private key from sender of Event (e.g. the key of an nip89 announcement you want to delete)
|
||||
fetch_nip89_paramters_for_deletion(keys, event_id, client, dvmconfig)
|
||||
|
||||
if adminconfig.UPDATE_PROFILE:
|
||||
update_profile(dvmconfig, lud16=adminconfig.LUD16)
|
||||
|
@ -34,9 +34,7 @@ def nip89_announce_tasks(dvm_config, client):
|
||||
print("Announced NIP 89 for " + dvm_config.NIP89.NAME)
|
||||
|
||||
|
||||
|
||||
def fetch_nip89_paramters_for_deletion( keys, eventid, client, dvmconfig):
|
||||
|
||||
def fetch_nip89_paramters_for_deletion(keys, eventid, client, dvmconfig):
|
||||
print("Pubkey generated from Private Key " + keys.public_key().to_hex())
|
||||
idfilter = Filter().id(EventId.from_hex(eventid)).limit(1)
|
||||
nip89events = client.get_events_of([idfilter], timedelta(seconds=dvmconfig.RELAY_TIMEOUT))
|
||||
@ -56,6 +54,7 @@ def fetch_nip89_paramters_for_deletion( keys, eventid, client, dvmconfig):
|
||||
nip89_delete_announcement(event_id, keys, d_tag, client, dvmconfig)
|
||||
print("NIP89 announcement deleted from known relays!")
|
||||
|
||||
|
||||
def nip89_delete_announcement(eid: str, keys: Keys, dtag: str, client: Client, config):
|
||||
e_tag = Tag.parse(["e", eid])
|
||||
a_tag = Tag.parse(["a", str(EventDefinitions.KIND_ANNOUNCEMENT) + ":" + keys.public_key().to_hex() + ":" + dtag])
|
||||
|
Loading…
x
Reference in New Issue
Block a user