From f85ae08db1dd6471d9e2d5edc28025684d0f3af4 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 12 May 2025 12:36:28 -0700 Subject: locked balance --- lib/locales/guided_translation.py | 17 ----------------- lib/locales/lang.json | 21 --------------------- lib/whitelist.ts | 1 + routes/users.ts | 3 ++- 4 files changed, 3 insertions(+), 39 deletions(-) delete mode 100644 lib/locales/lang.json diff --git a/lib/locales/guided_translation.py b/lib/locales/guided_translation.py index 15c5629b..a2f10177 100644 --- a/lib/locales/guided_translation.py +++ b/lib/locales/guided_translation.py @@ -4,7 +4,6 @@ import argparse, json, logging, sys, requests, os from pathlib import Path DEFAULT_FROM_LOCALE = 'en' -LOCALE_DATA_FILEPATH = 'lang.json' def nested_dict_keys(d, _keyname_prefix=''): entry_list = [] @@ -16,18 +15,6 @@ def nested_dict_keys(d, _keyname_prefix=''): entry_list += [_keyname_prefix + key] return entry_list -def create_locale(locale_code): - logging.debug("Creating locale %s...", locale_code) - with open(LOCALE_DATA_FILEPATH, 'r', encoding='utf-8') as lang_file: - lang_data = json.load(lang_file) - - lang_data[locale_code] = input("What is the name of the language " + locale_code + "? ") - - with open(LOCALE_DATA_FILEPATH, 'w') as lang_file: - json.dump(lang_data, lang_file, ensure_ascii=False, indent='\t') - lang_file.write('\n') - logging.debug("Created locale %s.", locale_code) - def localize_string(string_id, from_data, to_data, to_locale): api_key = os.environ.get('GOOGLE_API_KEY') logging.debug("Translating string with id %s", string_id) @@ -125,10 +112,6 @@ if __name__ == "__main__": to_json_text = to_file.read() logging.debug("Converting to data from JSON to object") to_data = json.loads(to_json_text) - else: - logging.info("No file found. Creating new locale.") - create_locale(to_locale) - to_data = {} to_id_list = nested_dict_keys(to_data) logging.info("Successfully obtained %d strings from locale %s", len(to_id_list), to_locale) diff --git a/lib/locales/lang.json b/lib/locales/lang.json deleted file mode 100644 index c4ce80b4..00000000 --- a/lib/locales/lang.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "en": "English", - "es": "Español", - "fr": "Français", - "de": "Deutsch", - "ja": "日本語", - "ru": "Русский", - "pt": "Português", - "zh": "中文", - "fa": "فارسی", - "el": "Ελληνικά", - "ar": "العربية", - "hi": "हिन्दी", - "bn": "বাংলা", - "tr": "Türkçe", - "ko": "한국어", - "it": "Italiano", - "nl": "Nederlands", - "th": "ไทย", - "pl": "Polski" -} diff --git a/lib/whitelist.ts b/lib/whitelist.ts index 07706432..5df18184 100644 --- a/lib/whitelist.ts +++ b/lib/whitelist.ts @@ -21,6 +21,7 @@ export default [ "keys", "language", "linked", + "locked", "locktime", "memoPrompt", "nip5", diff --git a/routes/users.ts b/routes/users.ts index ff69fbcf..6b73513b 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -2,7 +2,7 @@ import { createReadStream } from "node:fs"; import { appendFile, unlink } from "node:fs/promises"; import config from "$config"; import { requirePin } from "$lib/auth"; -import { db, g, s } from "$lib/db"; +import { db, g, ga, s } from "$lib/db"; import { err, l, warn } from "$lib/logging"; import { mail, templates } from "$lib/mail"; import { getNostrUser, getProfile, serverPubkey } from "$lib/nostr"; @@ -32,6 +32,7 @@ export default { const { user } = req; try { user.balance = await g(`balance:${user.id}`); + user.locked = await ga(`balance:${user.id}`); user.prompt = !!user.prompt; if (user.pubkey) user.npub = nip19.npubEncode(user.pubkey); -- cgit v1.2.3