Download ping
This commit is contained in:
@@ -70,7 +70,7 @@ const {
|
||||
const { applyCatalogGrounding, normalizeText } = require('./lib/scanGrounding');
|
||||
const { decideReviewOutcome, reviewAgreesWithPrimary } = require('./lib/scanReview');
|
||||
const { ensureStorageBucketWithRetry, uploadImage, isStorageConfigured } = require('./lib/storage');
|
||||
const { isPurchaseEventType, notifyPurchase, notifyNewUser } = require('./lib/discord');
|
||||
const { isPurchaseEventType, notifyPurchase, notifyNewUser, notifyDownload } = require('./lib/discord');
|
||||
const {
|
||||
exchangeCodeForTokens: exchangeTiktokCode,
|
||||
getTiktokTokens,
|
||||
@@ -1118,6 +1118,31 @@ app.post('/v1/upload/image', async (request, response) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Install ping ──────────────────────────────────────────────────────────
|
||||
|
||||
// Fired once by the app on first launch (unauthenticated — there is no account
|
||||
// yet). Deduped per install id so retries and reinstalls with a persisted id
|
||||
// don't ping the downloads channel twice.
|
||||
app.post('/v1/app-install', async (request, response) => {
|
||||
try {
|
||||
const installId = String(request.body?.installId || '').trim();
|
||||
if (!installId || installId.length > 128) {
|
||||
return response.status(400).json({ code: 'BAD_REQUEST', message: 'installId is required.' });
|
||||
}
|
||||
const isFirstReport = await claimNotificationOnce(db, `app-install:${installId}`);
|
||||
if (isFirstReport) {
|
||||
notifyDownload({
|
||||
platform: request.header('x-app-platform'),
|
||||
appVersion: request.header('x-app-version'),
|
||||
});
|
||||
}
|
||||
response.status(200).json({ ok: true });
|
||||
} catch (error) {
|
||||
const payload = toApiErrorPayload(error);
|
||||
response.status(payload.status).json(payload.body);
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Auth endpoints ────────────────────────────────────────────────────────
|
||||
|
||||
app.post('/auth/signup', async (request, response) => {
|
||||
|
||||
Reference in New Issue
Block a user