mass refactor
This commit is contained in:
@@ -139,7 +139,10 @@ export class CallbackHandlers {
|
||||
|
||||
// Просмотр анкет и свайпы
|
||||
else if (data === 'start_browsing') {
|
||||
await this.handleStartBrowsing(chatId, telegramId);
|
||||
await this.handleStartBrowsing(chatId, telegramId, false);
|
||||
} else if (data === 'start_browsing_first') {
|
||||
// Показываем всех пользователей для нового пользователя
|
||||
await this.handleStartBrowsing(chatId, telegramId, true);
|
||||
} else if (data === 'vip_search') {
|
||||
await this.handleVipSearch(chatId, telegramId);
|
||||
} else if (data.startsWith('search_by_goal_')) {
|
||||
@@ -330,7 +333,7 @@ export class CallbackHandlers {
|
||||
}
|
||||
|
||||
// Начать просмотр анкет
|
||||
async handleStartBrowsing(chatId: number, telegramId: string): Promise<void> {
|
||||
async handleStartBrowsing(chatId: number, telegramId: string, isNewUser: boolean = false): Promise<void> {
|
||||
const profile = await this.profileService.getProfileByTelegramId(telegramId);
|
||||
|
||||
if (!profile) {
|
||||
@@ -338,7 +341,7 @@ export class CallbackHandlers {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.showNextCandidate(chatId, telegramId);
|
||||
await this.showNextCandidate(chatId, telegramId, isNewUser);
|
||||
}
|
||||
|
||||
// Следующий кандидат
|
||||
@@ -891,8 +894,8 @@ export class CallbackHandlers {
|
||||
}
|
||||
}
|
||||
|
||||
async showNextCandidate(chatId: number, telegramId: string): Promise<void> {
|
||||
const candidate = await this.matchingService.getNextCandidate(telegramId);
|
||||
async showNextCandidate(chatId: number, telegramId: string, isNewUser: boolean = false): Promise<void> {
|
||||
const candidate = await this.matchingService.getNextCandidate(telegramId, isNewUser);
|
||||
|
||||
if (!candidate) {
|
||||
const keyboard: InlineKeyboardMarkup = {
|
||||
@@ -1370,12 +1373,28 @@ export class CallbackHandlers {
|
||||
return;
|
||||
}
|
||||
|
||||
const lifestyle = profile.lifestyle || {};
|
||||
lifestyle[type as keyof typeof lifestyle] = value as any;
|
||||
// Обновляем отдельные колонки напрямую, а не через объект lifestyle
|
||||
const updates: any = {};
|
||||
|
||||
switch (type) {
|
||||
case 'smoking':
|
||||
updates.smoking = value;
|
||||
break;
|
||||
case 'drinking':
|
||||
updates.drinking = value;
|
||||
break;
|
||||
case 'kids':
|
||||
// Для поля has_kids, которое имеет тип boolean, преобразуем строковые значения
|
||||
if (value === 'have') {
|
||||
updates.has_kids = true;
|
||||
} else {
|
||||
// Для 'want', 'dont_want', 'unsure' ставим false
|
||||
updates.has_kids = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
await this.profileService.updateProfile(profile.userId, {
|
||||
lifestyle: lifestyle
|
||||
});
|
||||
await this.profileService.updateProfile(profile.userId, updates);
|
||||
|
||||
const typeTexts: { [key: string]: string } = {
|
||||
'smoking': 'курение',
|
||||
|
||||
@@ -218,9 +218,10 @@ export class EnhancedChatHandlers {
|
||||
const messageId = await this.chatService.sendMessage(
|
||||
matchId,
|
||||
telegramId,
|
||||
msg.text || '[Медиа]',
|
||||
msg.photo ? 'photo' : 'text',
|
||||
msg.photo ? msg.photo[msg.photo.length - 1].file_id : undefined
|
||||
msg.photo ?
|
||||
(msg.caption || '[Фото]') + ' [file_id: ' + msg.photo[msg.photo.length - 1].file_id + ']' :
|
||||
(msg.text || '[Медиа]'),
|
||||
msg.photo ? 'photo' : 'text'
|
||||
);
|
||||
|
||||
if (messageId) {
|
||||
|
||||
@@ -217,11 +217,12 @@ export class MessageHandlers {
|
||||
}
|
||||
});
|
||||
|
||||
// Добавляем специальный callback для новых пользователей
|
||||
const keyboard: InlineKeyboardMarkup = {
|
||||
inline_keyboard: [
|
||||
[
|
||||
{ text: '👤 Мой профиль', callback_data: 'view_my_profile' },
|
||||
{ text: '🔍 Начать поиск', callback_data: 'start_browsing' }
|
||||
{ text: '🔍 Начать поиск', callback_data: 'start_browsing_first' }
|
||||
],
|
||||
[{ text: '⚙️ Настройки', callback_data: 'settings' }]
|
||||
]
|
||||
@@ -493,7 +494,7 @@ export class MessageHandlers {
|
||||
updates.hobbies = value;
|
||||
break;
|
||||
case 'city':
|
||||
// В БД поле называется 'location', но мы используем city в модели
|
||||
// В БД поле называется 'city' (не 'location')
|
||||
updates.city = value;
|
||||
break;
|
||||
case 'job':
|
||||
|
||||
Reference in New Issue
Block a user