feat(roles): let each section decide who may assign work to others
Section access now only creates a record for yourself. Assigning it to a colleague requires a separate permission on that section. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
elevated,
|
||||
ticketAccessWhere,
|
||||
} from '../common/record-scope';
|
||||
import { assertAssigneeSet } from '../common/assign-access';
|
||||
import { NotificationsService } from '../notifications/notifications.service';
|
||||
import { AutomationsService } from '../automations/automations.service';
|
||||
import { MessageAutomationsService } from '../message-automations/message-automations.service';
|
||||
@@ -136,9 +137,7 @@ export class TicketsService {
|
||||
if (assigneeId) {
|
||||
await this.assertUser(actor.organizationId, assigneeId);
|
||||
}
|
||||
if (!elevated(actor.role) && assigneeId && assigneeId !== actor.userId) {
|
||||
assigneeId = actor.userId;
|
||||
}
|
||||
await assertAssigneeSet(this.prisma, actor, 'tickets', [assigneeId]);
|
||||
|
||||
const number = await this.nextNumber(actor.organizationId);
|
||||
const status = (dto.status as never) || 'open';
|
||||
@@ -270,9 +269,7 @@ export class TicketsService {
|
||||
if ('assigneeId' in dto) {
|
||||
const next = emptyToNull(dto.assigneeId ?? null);
|
||||
if (next) await this.assertUser(actor.organizationId, next);
|
||||
if (!elevated(actor.role) && next && next !== actor.userId) {
|
||||
throw new BadRequestException('فقط میتوانید تیکت را به خودتان ارجاع دهید');
|
||||
}
|
||||
await assertAssigneeSet(this.prisma, actor, 'tickets', [next], [existing.assigneeId]);
|
||||
data.assigneeId = next;
|
||||
if (next && next !== existing.assigneeId && next !== actor.userId) {
|
||||
await this.notifications.create({
|
||||
|
||||
Reference in New Issue
Block a user