feat: VIP search now shows only opposite gender - Modified VIP search filtering to always show opposite gender regardless of user's interested_in preference - Male users see only female profiles - Female users see only male profiles - Improved gender filtering logic in vipService.ts
This commit is contained in:
@@ -6,6 +6,8 @@ import { Profile } from '../models/Profile';
|
||||
import { MessageHandlers } from './messageHandlers';
|
||||
import { ProfileEditController } from '../controllers/profileEditController';
|
||||
import { EnhancedChatHandlers } from './enhancedChatHandlers';
|
||||
import { VipController } from '../controllers/vipController';
|
||||
import { VipService } from '../services/vipService';
|
||||
|
||||
export class CallbackHandlers {
|
||||
private bot: TelegramBot;
|
||||
@@ -15,6 +17,8 @@ export class CallbackHandlers {
|
||||
private messageHandlers: MessageHandlers;
|
||||
private profileEditController: ProfileEditController;
|
||||
private enhancedChatHandlers: EnhancedChatHandlers;
|
||||
private vipController: VipController;
|
||||
private vipService: VipService;
|
||||
|
||||
constructor(bot: TelegramBot, messageHandlers: MessageHandlers) {
|
||||
this.bot = bot;
|
||||
@@ -24,6 +28,8 @@ export class CallbackHandlers {
|
||||
this.messageHandlers = messageHandlers;
|
||||
this.profileEditController = new ProfileEditController(this.profileService);
|
||||
this.enhancedChatHandlers = new EnhancedChatHandlers(bot);
|
||||
this.vipController = new VipController(bot);
|
||||
this.vipService = new VipService();
|
||||
}
|
||||
|
||||
register(): void {
|
||||
@@ -211,7 +217,30 @@ export class CallbackHandlers {
|
||||
} else if (data === 'back_to_browsing') {
|
||||
await this.handleStartBrowsing(chatId, telegramId);
|
||||
} else if (data === 'get_vip') {
|
||||
await this.handleGetVip(chatId, telegramId);
|
||||
await this.vipController.showVipSearch(chatId, telegramId);
|
||||
}
|
||||
|
||||
// VIP функции
|
||||
else if (data === 'vip_search') {
|
||||
await this.vipController.showVipSearch(chatId, telegramId);
|
||||
} else if (data === 'vip_quick_search') {
|
||||
await this.vipController.performQuickVipSearch(chatId, telegramId);
|
||||
} else if (data === 'vip_advanced_search') {
|
||||
await this.vipController.startAdvancedSearch(chatId, telegramId);
|
||||
} else if (data === 'vip_dating_goal_search') {
|
||||
await this.vipController.showDatingGoalSearch(chatId, telegramId);
|
||||
} else if (data.startsWith('vip_goal_')) {
|
||||
const goal = data.replace('vip_goal_', '');
|
||||
await this.vipController.performDatingGoalSearch(chatId, telegramId, goal);
|
||||
} else if (data.startsWith('vip_like_')) {
|
||||
const targetTelegramId = data.replace('vip_like_', '');
|
||||
await this.handleVipLike(chatId, telegramId, targetTelegramId);
|
||||
} else if (data.startsWith('vip_superlike_')) {
|
||||
const targetTelegramId = data.replace('vip_superlike_', '');
|
||||
await this.handleVipSuperlike(chatId, telegramId, targetTelegramId);
|
||||
} else if (data.startsWith('vip_dislike_')) {
|
||||
const targetTelegramId = data.replace('vip_dislike_', '');
|
||||
await this.handleVipDislike(chatId, telegramId, targetTelegramId);
|
||||
}
|
||||
|
||||
else {
|
||||
@@ -1724,20 +1753,30 @@ export class CallbackHandlers {
|
||||
const profile = await this.profileService.getProfileByTelegramId(telegramId);
|
||||
|
||||
if (profile) {
|
||||
const keyboard: InlineKeyboardMarkup = {
|
||||
inline_keyboard: [
|
||||
[
|
||||
{ text: '👤 Мой профиль', callback_data: 'view_my_profile' },
|
||||
{ text: '🔍 Просмотр анкет', callback_data: 'start_browsing' }
|
||||
],
|
||||
[
|
||||
{ text: '💕 Мои матчи', callback_data: 'view_matches' },
|
||||
{ text: '⭐ VIP поиск', callback_data: 'vip_search' }
|
||||
],
|
||||
[
|
||||
{ text: '⚙️ Настройки', callback_data: 'settings' }
|
||||
]
|
||||
// Проверяем премиум статус
|
||||
const premiumInfo = await this.vipService.checkPremiumStatus(telegramId);
|
||||
|
||||
let keyboardRows = [
|
||||
[
|
||||
{ text: '👤 Мой профиль', callback_data: 'view_my_profile' },
|
||||
{ text: '🔍 Просмотр анкет', callback_data: 'start_browsing' }
|
||||
],
|
||||
[
|
||||
{ text: '💕 Мои матчи', callback_data: 'view_matches' }
|
||||
]
|
||||
];
|
||||
|
||||
// Добавляем кнопку VIP поиска если есть премиум, или кнопку "Получить VIP" если нет
|
||||
if (premiumInfo && premiumInfo.isPremium) {
|
||||
keyboardRows[1].push({ text: '⭐ VIP поиск', callback_data: 'vip_search' });
|
||||
} else {
|
||||
keyboardRows[1].push({ text: '💎 Получить VIP', callback_data: 'get_vip' });
|
||||
}
|
||||
|
||||
keyboardRows.push([{ text: '⚙️ Настройки', callback_data: 'settings' }]);
|
||||
|
||||
const keyboard: InlineKeyboardMarkup = {
|
||||
inline_keyboard: keyboardRows
|
||||
};
|
||||
|
||||
await this.bot.sendMessage(
|
||||
@@ -1886,4 +1925,95 @@ export class CallbackHandlers {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// VIP лайк
|
||||
async handleVipLike(chatId: number, telegramId: string, targetTelegramId: string): Promise<void> {
|
||||
try {
|
||||
// Получаем user_id по telegram_id для совместимости с существующей логикой
|
||||
const targetUserId = await this.profileService.getUserIdByTelegramId(targetTelegramId);
|
||||
if (!targetUserId) {
|
||||
throw new Error('Target user not found');
|
||||
}
|
||||
|
||||
const result = await this.matchingService.performSwipe(telegramId, targetTelegramId, 'like');
|
||||
|
||||
if (result.isMatch) {
|
||||
// Это матч!
|
||||
const targetProfile = await this.profileService.getProfileByUserId(targetUserId);
|
||||
|
||||
const keyboard: InlineKeyboardMarkup = {
|
||||
inline_keyboard: [
|
||||
[
|
||||
{ text: '💬 Написать сообщение', callback_data: 'chat_' + targetUserId },
|
||||
{ text: '📱 Нативный чат', callback_data: 'open_native_chat_' + result.match?.id }
|
||||
],
|
||||
[{ text: '🔍 Продолжить VIP поиск', callback_data: 'vip_search' }]
|
||||
]
|
||||
};
|
||||
|
||||
await this.bot.sendMessage(
|
||||
chatId,
|
||||
'🎉 ЭТО МАТЧ! 💕\n\n' +
|
||||
'Вы понравились друг другу с ' + (targetProfile?.name || 'этим пользователем') + '!\n\n' +
|
||||
'Теперь вы можете начать общение!',
|
||||
{ reply_markup: keyboard }
|
||||
);
|
||||
} else {
|
||||
await this.bot.sendMessage(chatId, '👍 Лайк отправлен! Продолжайте VIP поиск.');
|
||||
}
|
||||
} catch (error) {
|
||||
await this.bot.sendMessage(chatId, '❌ Ошибка при отправке лайка');
|
||||
console.error('VIP Like error:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// VIP супер-лайк
|
||||
async handleVipSuperlike(chatId: number, telegramId: string, targetTelegramId: string): Promise<void> {
|
||||
try {
|
||||
const targetUserId = await this.profileService.getUserIdByTelegramId(targetTelegramId);
|
||||
if (!targetUserId) {
|
||||
throw new Error('Target user not found');
|
||||
}
|
||||
|
||||
const result = await this.matchingService.performSwipe(telegramId, targetTelegramId, 'superlike');
|
||||
|
||||
if (result.isMatch) {
|
||||
const targetProfile = await this.profileService.getProfileByUserId(targetUserId);
|
||||
|
||||
const keyboard: InlineKeyboardMarkup = {
|
||||
inline_keyboard: [
|
||||
[
|
||||
{ text: '💬 Написать сообщение', callback_data: 'chat_' + targetUserId },
|
||||
{ text: '📱 Нативный чат', callback_data: 'open_native_chat_' + result.match?.id }
|
||||
],
|
||||
[{ text: '🔍 Продолжить VIP поиск', callback_data: 'vip_search' }]
|
||||
]
|
||||
};
|
||||
|
||||
await this.bot.sendMessage(
|
||||
chatId,
|
||||
'⭐ СУПЕР МАТЧ! ⭐\n\n' +
|
||||
'Ваш супер-лайк привел к матчу с ' + (targetProfile?.name || 'этим пользователем') + '!\n\n' +
|
||||
'Начните общение прямо сейчас!',
|
||||
{ reply_markup: keyboard }
|
||||
);
|
||||
} else {
|
||||
await this.bot.sendMessage(chatId, '⭐ Супер-лайк отправлен! Это повышает ваши шансы.');
|
||||
}
|
||||
} catch (error) {
|
||||
await this.bot.sendMessage(chatId, '❌ Ошибка при отправке супер-лайка');
|
||||
console.error('VIP Superlike error:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// VIP дизлайк
|
||||
async handleVipDislike(chatId: number, telegramId: string, targetTelegramId: string): Promise<void> {
|
||||
try {
|
||||
await this.matchingService.performSwipe(telegramId, targetTelegramId, 'pass');
|
||||
await this.bot.sendMessage(chatId, '👎 Профиль пропущен. Продолжайте VIP поиск.');
|
||||
} catch (error) {
|
||||
await this.bot.sendMessage(chatId, '❌ Ошибка при выполнении действия');
|
||||
console.error('VIP Dislike error:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user