add two new permissions for notif and order
This commit is contained in:
@@ -31,6 +31,9 @@ export enum Permission {
|
|||||||
MANAGE_SCHEDULES = 'manage_schedules',
|
MANAGE_SCHEDULES = 'manage_schedules',
|
||||||
MANAGE_REPORTS = 'manage_reports',
|
MANAGE_REPORTS = 'manage_reports',
|
||||||
MANAGE_CONTACTS = 'manage_contacts',
|
MANAGE_CONTACTS = 'manage_contacts',
|
||||||
|
|
||||||
|
NEW_ORDER_NOTIFICATION='new_order_notification',
|
||||||
|
PAGER_NOTIFICATION='pager_notification'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,4 +58,6 @@ export const PermissionTitles: Record<Permission, string> = {
|
|||||||
[Permission.MANAGE_SCHEDULES]: 'مدیریت برنامهها',
|
[Permission.MANAGE_SCHEDULES]: 'مدیریت برنامهها',
|
||||||
[Permission.MANAGE_REPORTS]: 'مدیریت گزارشات',
|
[Permission.MANAGE_REPORTS]: 'مدیریت گزارشات',
|
||||||
[Permission.MANAGE_CONTACTS]: 'مدیریت تماسهای کاربران',
|
[Permission.MANAGE_CONTACTS]: 'مدیریت تماسهای کاربران',
|
||||||
|
[Permission.NEW_ORDER_NOTIFICATION]: "نوتیف سفارش جدید",
|
||||||
|
[Permission.PAGER_NOTIFICATION]: "نوتیف پیجر جدید"
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export class OrderListeners {
|
|||||||
|
|
||||||
|
|
||||||
// get admnin os restuaraant that have order permissuins
|
// get admnin os restuaraant that have order permissuins
|
||||||
const admins = await this.adminService.findAdminsWithPermission(event.restaurantId, Permission.MANAGE_ORDERS);
|
const admins = await this.adminService.findAdminsWithPermission(event.restaurantId, Permission.NEW_ORDER_NOTIFICATION);
|
||||||
const recipients = admins.map(admin => ({
|
const recipients = admins.map(admin => ({
|
||||||
adminId: admin.id,
|
adminId: admin.id,
|
||||||
}));
|
}));
|
||||||
@@ -118,35 +118,6 @@ export class OrderListeners {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const restaurant = await this.RestaurantRepository.findOne(event.restaurantId);
|
|
||||||
// if (!restaurant) {
|
|
||||||
// this.logger.log(
|
|
||||||
// `Restaurant not found for order: ${event.orderId} for restaurant: ${event.restaurantId} and order number: ${event.orderNumber}`,
|
|
||||||
// );
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// const score = restaurant.score;
|
|
||||||
// if (!score) {
|
|
||||||
// this.logger.log(
|
|
||||||
// `Score not found for restaurant: ${event.restaurantId} and order number: ${event.orderNumber}`,
|
|
||||||
// );
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// increase score for user
|
|
||||||
// const order = await this.OrderRepository.findOne(event.orderId);
|
|
||||||
// if (!order) {
|
|
||||||
// this.logger.log(
|
|
||||||
// `Order not found for order: ${event.orderId} for restaurant: ${event.restaurantId} and order number: ${event.orderNumber}`,
|
|
||||||
// );
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// this.userService.createWalletTransaction(event.userId, event.restaurantId, {
|
|
||||||
// amount: order.subTotal,
|
|
||||||
// type: WalletTransactionType.CREDIT,
|
|
||||||
// reason: WalletTransactionReason.ORDER_COMPLETED_DEPOSIT,
|
|
||||||
// });
|
|
||||||
|
|
||||||
await this.notificationService.sendNotification({
|
await this.notificationService.sendNotification({
|
||||||
restaurantId: event.restaurantId,
|
restaurantId: event.restaurantId,
|
||||||
message: {
|
message: {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export class PagerListeners {
|
|||||||
try {
|
try {
|
||||||
this.logger.log(`Pager created event received: ${event.restaurantId}`);
|
this.logger.log(`Pager created event received: ${event.restaurantId}`);
|
||||||
// get admnin os restuaraant that have pager permissuins
|
// get admnin os restuaraant that have pager permissuins
|
||||||
const admins = await this.adminService.findAdminsWithPermission(event.restaurantId, Permission.MANAGE_PAGER);
|
const admins = await this.adminService.findAdminsWithPermission(event.restaurantId, Permission.PAGER_NOTIFICATION);
|
||||||
const recipients = admins.map(admin => ({
|
const recipients = admins.map(admin => ({
|
||||||
adminId: admin.id,
|
adminId: admin.id,
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user