diff --git a/README.md b/README.md index dc32dab..29c5dc8 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ The Damus API backend for Damus Purple and other functionality. - `TESTFLIGHT_URL`: URL for the TestFlight app (optional) - `NOTEDECK_INSTALL_MD`: Path to the freely available notedeck installation instructions (markdown file) - `NOTEDECK_INSTALL_PREMIUM_MD`: Path to the premium notedeck installation instructions (markdown file) +- `DAMUS_ANDROID_INSTALL_MD`: Path to the freely available Damus Android installation instructions (markdown file) +- `DAMUS_ANDROID_INSTALL_PREMIUM_MD`: Path to the premium Damus Android installation instructions (markdown file) #### Translations diff --git a/damus-android-install-instructions-premium.md b/damus-android-install-instructions-premium.md new file mode 100644 index 0000000..b1afbb8 --- /dev/null +++ b/damus-android-install-instructions-premium.md @@ -0,0 +1,11 @@ +# Installing Damus Android + +Thank you for your interest in the Damus Android Beta release! As a Purple subscriber, you have access to our latest versions with new features before they reach the public release. Below are the instructions for installing the very latest Damus on your Android device. + +If you encounter any issues, please [contact us](support@damus.io). + +## Installation Options + +Please find the download link for your preferred installation method below: + +- Direct APK Download: [damus-android-beta-latest.apk](#) diff --git a/damus-android-install-instructions.md b/damus-android-install-instructions.md new file mode 100644 index 0000000..7c0bea3 --- /dev/null +++ b/damus-android-install-instructions.md @@ -0,0 +1,13 @@ +# Installing Damus Android + +Thank you for your interest in Damus Android! Below are the instructions for installing Damus on your Android device. + +If you encounter any issues, please [contact us](support@damus.io). + +## Installation Options + +Please find the download link for your preferred installation method below: + +- Google Play Store: [Damus on Google Play](#) +- Direct APK Download: [damus-android-latest.apk](#) +- F-Droid Repository: [Damus on F-Droid](#) diff --git a/package.json b/package.json index 125b387..0034e29 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,11 @@ "damus-api": "./src/index.js" }, "scripts": { - "test": "ALLOW_HTTP_AUTH=\"true\" DEEPL_KEY=123 TRANSLATION_PROVIDER=mock tap test/*.test.js", - "test-path": "ALLOW_HTTP_AUTH=\"true\" DEEPL_KEY=123 TRANSLATION_PROVIDER=mock tap", - "test-translate": "ALLOW_HTTP_AUTH=\"true\" TRANSLATION_PROVIDER=mock tap test/translate.test.js", - "test-noswhere": "ALLOW_HTTP_AUTH=\"true\" TRANSLATION_PROVIDER=noswhere tap test/translate.test.js", - "debug-test": "ALLOW_HTTP_AUTH=\"true\" TRANSLATION_PROVIDER=mock DEEPL_KEY=123 tap test/*.test.js --timeout=2400", + "test": "ALLOW_HTTP_AUTH=\"true\" DEEPL_KEY=123 TRANSLATION_PROVIDER=mock tap test/*.test.js --allow-incomplete-coverage", + "test-path": "ALLOW_HTTP_AUTH=\"true\" DEEPL_KEY=123 TRANSLATION_PROVIDER=mock tap --allow-incomplete-coverage", + "test-translate": "ALLOW_HTTP_AUTH=\"true\" TRANSLATION_PROVIDER=mock tap test/translate.test.js --allow-incomplete-coverage", + "test-noswhere": "ALLOW_HTTP_AUTH=\"true\" TRANSLATION_PROVIDER=noswhere tap test/translate.test.js --allow-incomplete-coverage", + "debug-test": "ALLOW_HTTP_AUTH=\"true\" TRANSLATION_PROVIDER=mock DEEPL_KEY=123 tap test/*.test.js --timeout=2400 --allow-incomplete-coverage", "start": "node src/index.js", "dev": "TRANSLATION_PROVIDER=mock ENABLE_HTTP_AUTH=\"true\" node src/index.js", "dev-debug": "TRANSLATION_PROVIDER=mock ENABLE_HTTP_AUTH=\"true\" node --inspect src/index.js", diff --git a/src/index.js b/src/index.js index c9c0c8a..6d67469 100755 --- a/src/index.js +++ b/src/index.js @@ -11,7 +11,7 @@ const { PurpleInvoiceManager } = require('./invoicing') const { WebAuthManager } = require('./web_auth') const { SimplePool } = require('nostr-tools/pool') -const ENV_VARS = ["LN_NODE_ID", "LN_NODE_ADDRESS", "LN_RUNE", "LN_WS_PROXY", "DEEPL_KEY", "DB_PATH", "NOTEDECK_INSTALL_MD"] +const ENV_VARS = ["LN_NODE_ID", "LN_NODE_ADDRESS", "LN_RUNE", "LN_WS_PROXY", "DEEPL_KEY", "DB_PATH", "NOTEDECK_INSTALL_MD", "NOTEDECK_INSTALL_PREMIUM_MD", "DAMUS_ANDROID_INSTALL_MD", "DAMUS_ANDROID_INSTALL_PREMIUM_MD"] function check_env() { const missing = [] diff --git a/src/router_config.js b/src/router_config.js index a8244f8..ec430a1 100644 --- a/src/router_config.js +++ b/src/router_config.js @@ -468,6 +468,29 @@ function config_router(app) { } }); + router.get('/damus-android-install-instructions', app.web_auth_manager.use_web_auth.bind(app.web_auth_manager), async (req, res) => { + if(!req.authorized_pubkey) { + provide_damus_android_instructions(req, res, false) // Provides free download instructions + return + } + + const { account, user_id } = get_account_and_user_id(app, req.authorized_pubkey) + if (!account) { + simple_response(res, 401) + return + } + + const account_info = get_account_info_payload(user_id, account, true) + if (account_info.active == true) { + provide_damus_android_instructions(req, res, true) // Provide premium download instructions + return + } + else { + provide_damus_android_instructions(req, res, false) // Provide free download instructions + return + } + }); + // MARK: Admin routes // Used by the admin to create a new verified checkout @@ -697,4 +720,18 @@ async function provide_notedeck_instructions(req, res, user_authenticated) { } } +async function provide_damus_android_instructions(req, res, user_authenticated) { + const installInstructionsPath = user_authenticated == true ? path.resolve(process.env.DAMUS_ANDROID_INSTALL_PREMIUM_MD) : path.resolve(process.env.DAMUS_ANDROID_INSTALL_MD); + try { + const installInstructions = fs.readFileSync(installInstructionsPath, { encoding: 'utf8' }); + json_response(res, { value: installInstructions }); + return + } catch (err) { + console.log(err); + error("Failed to read file: %s", err.toString()); + error_response(res, 'Failed to load installation instructions'); + return + } +} + module.exports = { config_router } diff --git a/test/controllers/purple_test_controller.js b/test/controllers/purple_test_controller.js index 618282d..aff3a3f 100644 --- a/test/controllers/purple_test_controller.js +++ b/test/controllers/purple_test_controller.js @@ -58,6 +58,8 @@ class PurpleTestController { process.env.TESTFLIGHT_URL = "https://testflight.apple.com/join/abc123" process.env.NOTEDECK_INSTALL_MD = "./notedeck-install-instructions.md" process.env.NOTEDECK_INSTALL_PREMIUM_MD = "./notedeck-install-instructions-premium.md" + process.env.DAMUS_ANDROID_INSTALL_MD = "./damus-android-install-instructions.md" + process.env.DAMUS_ANDROID_INSTALL_PREMIUM_MD = "./damus-android-install-instructions-premium.md" this.env = process.env }