feat: prompt users to start Telegram bot for notifications
This commit is contained in:
@@ -103,6 +103,10 @@ function applyDemoEmailAuthUser() {
|
||||
user_id: DEMO_DATASET.currentUser?.user_id || DEMO_DATASET.currentUser?.id || 910001,
|
||||
telegram_id: null,
|
||||
telegram_linked: false,
|
||||
telegram_notifications_status: "unknown",
|
||||
telegram_notifications_enabled: false,
|
||||
telegram_notifications_need_prompt: false,
|
||||
telegram_notifications_start_link: "https://t.me/preview_bot?start=notifications",
|
||||
telegram_photo_url: "",
|
||||
avatar_url: "",
|
||||
username: DEMO_DATASET.currentUser?.username || "u3252a8",
|
||||
@@ -181,6 +185,10 @@ function applyDemoTelegramAuthUser(authData = {}) {
|
||||
user_id: adminUser.user_id || adminUser.id || 910001,
|
||||
telegram_id: telegramId,
|
||||
telegram_linked: true,
|
||||
telegram_notifications_status: "needs_start",
|
||||
telegram_notifications_enabled: false,
|
||||
telegram_notifications_need_prompt: true,
|
||||
telegram_notifications_start_link: "https://t.me/preview_bot?start=notifications",
|
||||
username,
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
@@ -258,6 +266,10 @@ function applyDemoTelegramLink(authData = {}) {
|
||||
user_id: DEV_MOCK.data.user?.user_id || DEV_MOCK.data.user?.id || 910001,
|
||||
telegram_id: telegramId,
|
||||
telegram_linked: true,
|
||||
telegram_notifications_status: "needs_start",
|
||||
telegram_notifications_enabled: false,
|
||||
telegram_notifications_need_prompt: true,
|
||||
telegram_notifications_start_link: "https://t.me/preview_bot?start=notifications",
|
||||
username:
|
||||
authData.username ||
|
||||
authDemo.telegram_username ||
|
||||
@@ -1991,6 +2003,27 @@ export async function mockApi(path, options = {}, context = {}) {
|
||||
applyDemoTelegramLink(body.auth_data || {});
|
||||
return { ok: true, csrf_token: "local-preview-csrf" };
|
||||
}
|
||||
if (
|
||||
path === "/account/telegram/notifications/probe" &&
|
||||
String(options.method || "").toUpperCase() === "POST"
|
||||
) {
|
||||
DEV_MOCK.data.user = {
|
||||
...(DEV_MOCK.data.user || {}),
|
||||
telegram_notifications_status: "enabled",
|
||||
telegram_notifications_enabled: true,
|
||||
telegram_notifications_need_prompt: false,
|
||||
telegram_notifications_start_link: "https://t.me/preview_bot?start=notifications",
|
||||
};
|
||||
return {
|
||||
ok: true,
|
||||
telegram_notifications: {
|
||||
ok: true,
|
||||
status: "enabled",
|
||||
enabled: true,
|
||||
start_link: "https://t.me/preview_bot?start=notifications",
|
||||
},
|
||||
};
|
||||
}
|
||||
if (path === "/payments" && String(options.method || "").toUpperCase() === "POST") {
|
||||
const body = jsonBody(options);
|
||||
if (isDeviceTopupSaleMode(body.sale_mode)) {
|
||||
|
||||
@@ -288,6 +288,10 @@ export const DEV_MOCK = {
|
||||
password_auth_enabled: false,
|
||||
telegram_id: 100200300,
|
||||
telegram_linked: true,
|
||||
telegram_notifications_status: "enabled",
|
||||
telegram_notifications_enabled: true,
|
||||
telegram_notifications_need_prompt: false,
|
||||
telegram_notifications_start_link: "https://t.me/preview_bot?start=notifications",
|
||||
telegram_photo_url: "",
|
||||
first_name: "Preview",
|
||||
language_code: "ru",
|
||||
@@ -457,6 +461,15 @@ function applyDemoDataset() {
|
||||
...(DEMO_DATASET.currentUser || {}),
|
||||
id: DEMO_DATASET.currentUser?.id ?? DEMO_DATASET.currentUser?.user_id,
|
||||
language_code: storedLanguage || DEMO_DATASET.currentUser?.language_code || "ru",
|
||||
telegram_notifications_status:
|
||||
DEMO_DATASET.currentUser?.telegram_notifications_status || "enabled",
|
||||
telegram_notifications_enabled:
|
||||
DEMO_DATASET.currentUser?.telegram_notifications_enabled ?? true,
|
||||
telegram_notifications_need_prompt:
|
||||
DEMO_DATASET.currentUser?.telegram_notifications_need_prompt ?? false,
|
||||
telegram_notifications_start_link:
|
||||
DEMO_DATASET.currentUser?.telegram_notifications_start_link ||
|
||||
"https://t.me/preview_bot?start=notifications",
|
||||
},
|
||||
160
|
||||
);
|
||||
@@ -588,6 +601,30 @@ export function applyPreviewMock(kind) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode === "notifications" || mode === "telegram-notifications" || mode === "needs-bot") {
|
||||
DEV_MOCK.data.user = {
|
||||
...(DEV_MOCK.data.user || {}),
|
||||
telegram_linked: true,
|
||||
telegram_notifications_status: "needs_start",
|
||||
telegram_notifications_enabled: false,
|
||||
telegram_notifications_need_prompt: true,
|
||||
telegram_notifications_start_link: "https://t.me/preview_bot?start=notifications",
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode === "notifications-blocked") {
|
||||
DEV_MOCK.data.user = {
|
||||
...(DEV_MOCK.data.user || {}),
|
||||
telegram_linked: true,
|
||||
telegram_notifications_status: "blocked",
|
||||
telegram_notifications_enabled: false,
|
||||
telegram_notifications_need_prompt: true,
|
||||
telegram_notifications_start_link: "https://t.me/preview_bot?start=notifications",
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode === "tariffs") {
|
||||
DEV_MOCK.data.settings.traffic_mode = false;
|
||||
if (DEMO_DATASET.plans?.length) {
|
||||
|
||||
Reference in New Issue
Block a user