mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-04 13:48:56 +02:00
feat: add group-deleted event (#4816)
Adds a missing `group-deleted` event.
This commit is contained in:
parent
b4742df8be
commit
b6b0f83e3d
@ -11,7 +11,7 @@ import { IUnleashConfig, IUnleashStores } from '../types';
|
|||||||
import { IGroupStore } from '../types/stores/group-store';
|
import { IGroupStore } from '../types/stores/group-store';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import BadDataError from '../error/bad-data-error';
|
import BadDataError from '../error/bad-data-error';
|
||||||
import { GROUP_CREATED, GROUP_UPDATED } from '../types/events';
|
import { GROUP_CREATED, GROUP_DELETED, GROUP_UPDATED } from '../types/events';
|
||||||
import { IEventStore } from '../types/stores/event-store';
|
import { IEventStore } from '../types/stores/event-store';
|
||||||
import NameExistsError from '../error/name-exists-error';
|
import NameExistsError from '../error/name-exists-error';
|
||||||
import { IAccountStore } from '../types/stores/account-store';
|
import { IAccountStore } from '../types/stores/account-store';
|
||||||
@ -170,8 +170,18 @@ export class GroupService {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteGroup(id: number): Promise<void> {
|
async deleteGroup(id: number, userName?: string): Promise<void> {
|
||||||
return this.groupStore.delete(id);
|
const group = await this.groupStore.get(id);
|
||||||
|
|
||||||
|
await this.groupStore.delete(id);
|
||||||
|
|
||||||
|
if (userName) {
|
||||||
|
await this.eventStore.store({
|
||||||
|
type: GROUP_DELETED,
|
||||||
|
createdBy: userName,
|
||||||
|
data: group,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateGroup(
|
async validateGroup(
|
||||||
|
@ -90,6 +90,7 @@ export const SEGMENT_UPDATED = 'segment-updated' as const;
|
|||||||
export const SEGMENT_DELETED = 'segment-deleted' as const;
|
export const SEGMENT_DELETED = 'segment-deleted' as const;
|
||||||
export const GROUP_CREATED = 'group-created' as const;
|
export const GROUP_CREATED = 'group-created' as const;
|
||||||
export const GROUP_UPDATED = 'group-updated' as const;
|
export const GROUP_UPDATED = 'group-updated' as const;
|
||||||
|
export const GROUP_DELETED = 'group-deleted' as const;
|
||||||
export const SETTING_CREATED = 'setting-created' as const;
|
export const SETTING_CREATED = 'setting-created' as const;
|
||||||
export const SETTING_UPDATED = 'setting-updated' as const;
|
export const SETTING_UPDATED = 'setting-updated' as const;
|
||||||
export const SETTING_DELETED = 'setting-deleted' as const;
|
export const SETTING_DELETED = 'setting-deleted' as const;
|
||||||
@ -213,6 +214,7 @@ export const IEventTypes = [
|
|||||||
SEGMENT_DELETED,
|
SEGMENT_DELETED,
|
||||||
GROUP_CREATED,
|
GROUP_CREATED,
|
||||||
GROUP_UPDATED,
|
GROUP_UPDATED,
|
||||||
|
GROUP_DELETED,
|
||||||
SETTING_CREATED,
|
SETTING_CREATED,
|
||||||
SETTING_UPDATED,
|
SETTING_UPDATED,
|
||||||
SETTING_DELETED,
|
SETTING_DELETED,
|
||||||
|
Loading…
Reference in New Issue
Block a user