|
|
|
@ -219,11 +219,15 @@ export class TasksService implements Tasks.ITasksService {
@@ -219,11 +219,15 @@ export class TasksService implements Tasks.ITasksService {
|
|
|
|
|
doneDate: new Date(date).toISOString(), |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
await this.afterSaveTask('task/finish-task', { |
|
|
|
|
taskId: id, |
|
|
|
|
executorId: task.executorId, |
|
|
|
|
events: this.transformEvents(task.events), |
|
|
|
|
}) |
|
|
|
|
await this.afterSaveTask( |
|
|
|
|
'task/finish-task', |
|
|
|
|
{ |
|
|
|
|
taskId: id, |
|
|
|
|
executorId: task.executorId, |
|
|
|
|
events: this.transformEvents(task.events), |
|
|
|
|
}, |
|
|
|
|
task.isReadByAll, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
this.eventEmitter.emit(Events.OnUpdateEntity, { |
|
|
|
|
type: Versions.EntityType.Task, |
|
|
|
@ -299,11 +303,15 @@ export class TasksService implements Tasks.ITasksService {
@@ -299,11 +303,15 @@ export class TasksService implements Tasks.ITasksService {
|
|
|
|
|
status: Tasks.Status.Deleted, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
await this.afterSaveTask('task/delete-task', { |
|
|
|
|
taskId: id, |
|
|
|
|
executorId: task.executorId, |
|
|
|
|
events: this.transformEvents(task.events), |
|
|
|
|
}) |
|
|
|
|
await this.afterSaveTask( |
|
|
|
|
'task/delete-task', |
|
|
|
|
{ |
|
|
|
|
taskId: id, |
|
|
|
|
executorId: task.executorId, |
|
|
|
|
events: this.transformEvents(task.events), |
|
|
|
|
}, |
|
|
|
|
task.isReadByAll, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
this.eventEmitter.emit(Events.OnUpdateEntity, { |
|
|
|
|
type: Versions.EntityType.Task, |
|
|
|
@ -571,6 +579,7 @@ export class TasksService implements Tasks.ITasksService {
@@ -571,6 +579,7 @@ export class TasksService implements Tasks.ITasksService {
|
|
|
|
|
.createQueryBuilder('it') |
|
|
|
|
.leftJoinAndSelect('it.events', 'events') |
|
|
|
|
.andWhere('it.status = :active', { active: Tasks.Status.Active }) |
|
|
|
|
.andWhere('it.isReadByAll IS NOT TRUE') |
|
|
|
|
|
|
|
|
|
const role = await this.usersService.getUserRole(userId) |
|
|
|
|
|
|
|
|
@ -610,9 +619,13 @@ export class TasksService implements Tasks.ITasksService {
@@ -610,9 +619,13 @@ export class TasksService implements Tasks.ITasksService {
|
|
|
|
|
return _.uniq(userIds) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private async afterSaveTask(eventKey: string, data?: any) { |
|
|
|
|
private async afterSaveTask(eventKey: string, data?: any, addReadByUser?: boolean) { |
|
|
|
|
const usersIds = await this.wsService.getUsersOnlineIds() |
|
|
|
|
usersIds.map(it => this.wsService.emitToUser(it, eventKey, data)) |
|
|
|
|
usersIds.map(it => { |
|
|
|
|
if (addReadByUser && data.events) data.events.push({ [it]: Tasks.Event.Read }) |
|
|
|
|
|
|
|
|
|
this.wsService.emitToUser(it, eventKey, data) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private transformEvents(events: Tasks.ITaskEvent[]): Record<string, Tasks.Event>[] { |
|
|
|
|