-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into N21-2103-update-media-activations
- Loading branch information
Showing
43 changed files
with
793 additions
and
200 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
apps/server/src/infra/schulconnex-client/schulconnex-client-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
apps/server/src/migrations/mikro-orm/Migration20241209165812.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Migration } from '@mikro-orm/migrations-mongodb'; | ||
|
||
export class Migration20241209165812 extends Migration { | ||
async up(): Promise<void> { | ||
// Add ROOM_OWNER role | ||
await this.getCollection('roles').insertOne({ | ||
name: 'roomowner', | ||
permissions: [ | ||
'ROOM_VIEW', | ||
'ROOM_EDIT', | ||
'ROOM_DELETE', | ||
'ROOM_MEMBERS_ADD', | ||
'ROOM_MEMBERS_REMOVE', | ||
'ROOM_CHANGE_OWNER', | ||
], | ||
}); | ||
console.info( | ||
'Added ROOM_OWNER role with ROOM_VIEW, -_EDIT, _DELETE, -_MEMBERS_ADD, -_MEMBERS_REMOVE AND -_CHANGE_OWNER permission' | ||
); | ||
|
||
// Add ROOM_ADMIN role | ||
await this.getCollection('roles').insertOne({ | ||
name: 'roomadmin', | ||
permissions: ['ROOM_VIEW', 'ROOM_EDIT', 'ROOM_MEMBERS_ADD', 'ROOM_MEMBERS_REMOVE'], | ||
}); | ||
console.info( | ||
'Added ROOM_ADMIN role with ROOM_VIEW, ROOM_EDIT, ROOM_MEMBERS_ADD AND ROOM_MEMBERS_REMOVE permissions' | ||
); | ||
} | ||
|
||
async down(): Promise<void> { | ||
// Remove ROOM_OWNER role | ||
await this.getCollection('roles').deleteOne({ name: 'roomowner' }); | ||
console.info('Rollback: Removed ROOM_OWNER role'); | ||
|
||
// Remove ROOM_ADMIN role | ||
await this.getCollection('roles').deleteOne({ name: 'roomadmin' }); | ||
console.info('Rollback: Removed ROOM_ADMIN role'); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
apps/server/src/migrations/mikro-orm/Migration20241210152600.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Migration } from '@mikro-orm/migrations-mongodb'; | ||
|
||
export class Migration20241210152600 extends Migration { | ||
async up(): Promise<void> { | ||
const roomEditorRoleUpdate = await this.getCollection('roles').updateOne( | ||
{ name: 'roomeditor' }, | ||
{ | ||
$set: { | ||
permissions: ['ROOM_VIEW', 'ROOM_EDIT'], | ||
}, | ||
} | ||
); | ||
|
||
if (roomEditorRoleUpdate.modifiedCount > 0) { | ||
console.info('Permission ROOM_DELETE removed from role roomeditor.'); | ||
} | ||
} | ||
|
||
async down(): Promise<void> { | ||
const roomEditorRoleUpdate = await this.getCollection('roles').updateOne( | ||
{ name: 'roomeditor' }, | ||
{ | ||
$set: { | ||
permissions: ['ROOM_VIEW', 'ROOM_EDIT', 'ROOM_DELETE'], | ||
}, | ||
} | ||
); | ||
|
||
if (roomEditorRoleUpdate.modifiedCount > 0) { | ||
console.info( | ||
'Rollback: Permissions ROOM_DELETE added to and ROOM_MEMBERS_ADD and ROOM_MEMBERS_REMOVE removed from role roomeditor.' | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
apps/server/src/modules/provisioning/loggable/group-provisioning-info.loggable.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { externalGroupDtoFactory, externalGroupUserDtoFactory } from '../testing'; | ||
import { GroupProvisioningInfoLoggable } from './group-provisioning-info.loggable'; | ||
|
||
describe(GroupProvisioningInfoLoggable.name, () => { | ||
describe('getLogMessage', () => { | ||
const setup = () => { | ||
const groupCount = 2; | ||
const otherUserCount = 5; | ||
const totalUserCount = groupCount * otherUserCount + groupCount; | ||
const externalGroups = externalGroupDtoFactory.buildList(groupCount, { | ||
otherUsers: externalGroupUserDtoFactory.buildList(otherUserCount), | ||
}); | ||
|
||
const loggable = new GroupProvisioningInfoLoggable(externalGroups, 100); | ||
|
||
return { | ||
loggable, | ||
totalUserCount, | ||
groupCount, | ||
}; | ||
}; | ||
|
||
it('should return a loggable message', () => { | ||
const { loggable, totalUserCount, groupCount } = setup(); | ||
|
||
const message = loggable.getLogMessage(); | ||
|
||
expect(message).toEqual({ | ||
message: 'Group provisioning has finished.', | ||
data: { | ||
groupCount, | ||
userCount: totalUserCount, | ||
durationMs: 100, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
apps/server/src/modules/provisioning/loggable/group-provisioning-info.loggable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger'; | ||
import { ExternalGroupDto } from '../dto'; | ||
|
||
export class GroupProvisioningInfoLoggable implements Loggable { | ||
constructor(private readonly groups: ExternalGroupDto[], private readonly durationMs: number) {} | ||
|
||
public getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage { | ||
const userCount = this.groups.reduce( | ||
(count: number, group: ExternalGroupDto) => count + (group.otherUsers?.length ?? 0), | ||
this.groups.length | ||
); | ||
|
||
return { | ||
message: 'Group provisioning has finished.', | ||
data: { | ||
groupCount: this.groups.length, | ||
userCount, | ||
durationMs: this.durationMs, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.