Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions damus-android-install-instructions-premium.md
Original file line number Diff line number Diff line change
@@ -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]([email protected]).

## Installation Options

Please find the download link for your preferred installation method below:

- Direct APK Download: [damus-android-beta-latest.apk](#)
13 changes: 13 additions & 0 deletions damus-android-install-instructions.md
Original file line number Diff line number Diff line change
@@ -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]([email protected]).

## 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](#)
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
37 changes: 37 additions & 0 deletions src/router_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
2 changes: 2 additions & 0 deletions test/controllers/purple_test_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down