diff --git a/index.js b/index.js index 671b602..fcc78a4 100644 --- a/index.js +++ b/index.js @@ -2290,64 +2290,40 @@ async function linkedUsernameError(ctx) { async function deleteEphemeralBonusPrompt(ctx, user) { - const activePrompt = await runUserMutation(user.id, async () => { - if (!user.ephemeralBonusMsgId || !user.ephemeralBonusChatId) return null; - return { msgId: user.ephemeralBonusMsgId, chatId: user.ephemeralBonusChatId }; - }); - if (!activePrompt) return; - + if (!user.ephemeralBonusMsgId || !user.ephemeralBonusChatId) return; try { - await ctx.telegram.deleteMessage(activePrompt.chatId, activePrompt.msgId); + await ctx.telegram.deleteMessage(user.ephemeralBonusChatId, user.ephemeralBonusMsgId); } catch (_) { /* message may already be gone */ } - - await runUserMutation(user.id, async () => { - if (user.ephemeralBonusMsgId === activePrompt.msgId && user.ephemeralBonusChatId === activePrompt.chatId) { - user.ephemeralBonusMsgId = null; - user.ephemeralBonusChatId = null; - } - }); + user.ephemeralBonusMsgId = null; + user.ephemeralBonusChatId = null; } async function sendEphemeralBonusPrompt(ctx, user) { - if (user.claimedPromo) return; - const activeCode = getActivePromoCodeForUser(user); - if (!activeCode) return; - await deleteEphemeralBonusPrompt(ctx, user); - const sent = await ctx.reply( `🎁 *Claim Your New User Bonus* -Enter promo code *${activeCode.code}* on the Runewager affiliate page to claim your ${activeCode.amountSC} SC new user bonus!`, +Enter promo code *${promoStore.code}* on the Runewager affiliate page to claim your ${promoStore.amountSC} SC new user bonus!`, { parse_mode: 'Markdown', ...Markup.inlineKeyboard([ [Markup.button.url('🎁 Enter Promo Code (Mini App)', LINKS.miniAppClaim)], - [Markup.button.callback('✅ I Have Claimed — Next Step', 'promo_confirm_claimed_next')], [Markup.button.callback('⬅️ Main Menu', 'to_main_menu')], ]), }, ); - - await runUserMutation(user.id, async () => { - user.ephemeralBonusMsgId = sent.message_id; - user.ephemeralBonusChatId = sent.chat.id; - }); - + user.ephemeralBonusMsgId = sent.message_id; + user.ephemeralBonusChatId = sent.chat.id; setTimeout(async () => { try { await ctx.telegram.deleteMessage(sent.chat.id, sent.message_id); } catch (_) { /* best effort */ } - - await runUserMutation(user.id, async () => { - if (user.ephemeralBonusMsgId === sent.message_id && user.ephemeralBonusChatId === sent.chat.id) { - user.ephemeralBonusMsgId = null; - user.ephemeralBonusChatId = null; - } - }); + if (user.ephemeralBonusMsgId === sent.message_id && user.ephemeralBonusChatId === sent.chat.id) { + user.ephemeralBonusMsgId = null; + user.ephemeralBonusChatId = null; + } }, 15 * 1000); } - const adminEventsLogFile = path.join(dataDir, 'admin-events.log'); const ADMIN_LOG_CAP = 200; diff --git a/prod-run.sh b/prod-run.sh index 1a3c9b3..49ef908 100755 --- a/prod-run.sh +++ b/prod-run.sh @@ -199,12 +199,6 @@ mkdir -p "$PROJECT_DIR/data" mkdir -p "$PROJECT_DIR/data/backups" touch "$MAIN_LOG" "$ERROR_LOG" "$ADMIN_EVENTS_LOG" "$SSHV_SESSIONS_FILE" # create if missing; safe on existing files -if id -u "$SERVICE_USER" >/dev/null 2>&1; then - chown -R "$SERVICE_USER:$SERVICE_GROUP" "$LOG_DIR" "$PROJECT_DIR/data" -fi -chmod 0750 "$PROJECT_DIR/data" "$PROJECT_DIR/data/backups" "$LOG_DIR" -chmod 0640 "$MAIN_LOG" "$ERROR_LOG" "$ADMIN_EVENTS_LOG" "$SSHV_SESSIONS_FILE" - say "Ensured runtime directories and log files exist" # ---------------------------------------------------------