admin access
This commit is contained in:
@@ -1,12 +1,18 @@
|
|||||||
import db from '../config/database.js';
|
import db from '../config/database.js';
|
||||||
import Validators from '../utils/validators.js';
|
import config from "../config/config.js";
|
||||||
|
|
||||||
export default class AdminUserLocationHandler {
|
export default class AdminUserLocationHandler {
|
||||||
constructor(bot) {
|
constructor(bot) {
|
||||||
this.bot = bot;
|
this.bot = bot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isAdmin(userId) {
|
||||||
|
return config.ADMIN_IDS.includes(userId.toString());
|
||||||
|
}
|
||||||
|
|
||||||
async handleEditUserLocation(callbackQuery) {
|
async handleEditUserLocation(callbackQuery) {
|
||||||
|
if (!this.isAdmin(callbackQuery.from.id)) return;
|
||||||
|
|
||||||
const userId = callbackQuery.data.replace('edit_user_location_', '');
|
const userId = callbackQuery.data.replace('edit_user_location_', '');
|
||||||
const chatId = callbackQuery.message.chat.id;
|
const chatId = callbackQuery.message.chat.id;
|
||||||
const messageId = callbackQuery.message.message_id;
|
const messageId = callbackQuery.message.message_id;
|
||||||
@@ -55,6 +61,8 @@ export default class AdminUserLocationHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async handleEditUserCountry(callbackQuery) {
|
async handleEditUserCountry(callbackQuery) {
|
||||||
|
if (!this.isAdmin(callbackQuery.from.id)) return;
|
||||||
|
|
||||||
const chatId = callbackQuery.message.chat.id;
|
const chatId = callbackQuery.message.chat.id;
|
||||||
const messageId = callbackQuery.message.message_id;
|
const messageId = callbackQuery.message.message_id;
|
||||||
const [country, userId] = callbackQuery.data.replace('edit_user_country_', '').split("_");
|
const [country, userId] = callbackQuery.data.replace('edit_user_country_', '').split("_");
|
||||||
@@ -90,6 +98,8 @@ export default class AdminUserLocationHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async handleEditUserCity(callbackQuery) {
|
async handleEditUserCity(callbackQuery) {
|
||||||
|
if (!this.isAdmin(callbackQuery.from.id)) return;
|
||||||
|
|
||||||
const chatId = callbackQuery.message.chat.id;
|
const chatId = callbackQuery.message.chat.id;
|
||||||
const messageId = callbackQuery.message.message_id;
|
const messageId = callbackQuery.message.message_id;
|
||||||
const [country, city, userId] = callbackQuery.data.replace('edit_user_city_', '').split('_');
|
const [country, city, userId] = callbackQuery.data.replace('edit_user_city_', '').split('_');
|
||||||
@@ -125,6 +135,8 @@ export default class AdminUserLocationHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async handleEditUserDistrict(callbackQuery) {
|
async handleEditUserDistrict(callbackQuery) {
|
||||||
|
if (!this.isAdmin(callbackQuery.from.id)) return;
|
||||||
|
|
||||||
const chatId = callbackQuery.message.chat.id;
|
const chatId = callbackQuery.message.chat.id;
|
||||||
const messageId = callbackQuery.message.message_id;
|
const messageId = callbackQuery.message.message_id;
|
||||||
const [country, city, district, userId] = callbackQuery.data.replace('edit_user_district_', '').split('_');
|
const [country, city, district, userId] = callbackQuery.data.replace('edit_user_district_', '').split('_');
|
||||||
|
|||||||
Reference in New Issue
Block a user