admin access
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
import db from '../config/database.js';
|
||||
import Validators from '../utils/validators.js';
|
||||
import config from "../config/config.js";
|
||||
|
||||
export default class AdminUserLocationHandler {
|
||||
constructor(bot) {
|
||||
this.bot = bot;
|
||||
}
|
||||
|
||||
isAdmin(userId) {
|
||||
return config.ADMIN_IDS.includes(userId.toString());
|
||||
}
|
||||
|
||||
async handleEditUserLocation(callbackQuery) {
|
||||
if (!this.isAdmin(callbackQuery.from.id)) return;
|
||||
|
||||
const userId = callbackQuery.data.replace('edit_user_location_', '');
|
||||
const chatId = callbackQuery.message.chat.id;
|
||||
const messageId = callbackQuery.message.message_id;
|
||||
@@ -22,7 +28,7 @@ export default class AdminUserLocationHandler {
|
||||
message_id: messageId,
|
||||
reply_markup: {
|
||||
inline_keyboard: [[
|
||||
{ text: '« Back to User', callback_data: `view_user_${userId}` }
|
||||
{text: '« Back to User', callback_data: `view_user_${userId}`}
|
||||
]]
|
||||
}
|
||||
}
|
||||
@@ -36,7 +42,7 @@ export default class AdminUserLocationHandler {
|
||||
text: loc.country,
|
||||
callback_data: `edit_user_country_${loc.country}_${userId}`
|
||||
}]),
|
||||
[{ text: '« Back to User', callback_data: `view_user_${userId}` }]
|
||||
[{text: '« Back to User', callback_data: `view_user_${userId}`}]
|
||||
]
|
||||
};
|
||||
|
||||
@@ -55,6 +61,8 @@ export default class AdminUserLocationHandler {
|
||||
}
|
||||
|
||||
async handleEditUserCountry(callbackQuery) {
|
||||
if (!this.isAdmin(callbackQuery.from.id)) return;
|
||||
|
||||
const chatId = callbackQuery.message.chat.id;
|
||||
const messageId = callbackQuery.message.message_id;
|
||||
const [country, userId] = callbackQuery.data.replace('edit_user_country_', '').split("_");
|
||||
@@ -71,7 +79,7 @@ export default class AdminUserLocationHandler {
|
||||
text: loc.city,
|
||||
callback_data: `edit_user_city_${country}_${loc.city}_${userId}`
|
||||
}]),
|
||||
[{ text: '« Back to Countries', callback_data: `edit_user_location_${userId}` }]
|
||||
[{text: '« Back to Countries', callback_data: `edit_user_location_${userId}`}]
|
||||
]
|
||||
};
|
||||
|
||||
@@ -90,6 +98,8 @@ export default class AdminUserLocationHandler {
|
||||
}
|
||||
|
||||
async handleEditUserCity(callbackQuery) {
|
||||
if (!this.isAdmin(callbackQuery.from.id)) return;
|
||||
|
||||
const chatId = callbackQuery.message.chat.id;
|
||||
const messageId = callbackQuery.message.message_id;
|
||||
const [country, city, userId] = callbackQuery.data.replace('edit_user_city_', '').split('_');
|
||||
@@ -106,7 +116,7 @@ export default class AdminUserLocationHandler {
|
||||
text: loc.district,
|
||||
callback_data: `edit_user_district_${country}_${city}_${loc.district}_${userId}`
|
||||
}]),
|
||||
[{ text: '« Back to Cities', callback_data: `edit_user_country_${country}_${userId}` }]
|
||||
[{text: '« Back to Cities', callback_data: `edit_user_country_${country}_${userId}`}]
|
||||
]
|
||||
};
|
||||
|
||||
@@ -125,6 +135,8 @@ export default class AdminUserLocationHandler {
|
||||
}
|
||||
|
||||
async handleEditUserDistrict(callbackQuery) {
|
||||
if (!this.isAdmin(callbackQuery.from.id)) return;
|
||||
|
||||
const chatId = callbackQuery.message.chat.id;
|
||||
const messageId = callbackQuery.message.message_id;
|
||||
const [country, city, district, userId] = callbackQuery.data.replace('edit_user_district_', '').split('_');
|
||||
@@ -146,7 +158,7 @@ export default class AdminUserLocationHandler {
|
||||
message_id: messageId,
|
||||
reply_markup: {
|
||||
inline_keyboard: [[
|
||||
{ text: '« Back to User', callback_data: `view_user_${userId}` }
|
||||
{text: '« Back to User', callback_data: `view_user_${userId}`}
|
||||
]]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user