-
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.
- Loading branch information
1 parent
abd4cf1
commit b118570
Showing
5 changed files
with
64 additions
and
26 deletions.
There are no files selected for viewing
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/modules/h5p-library-management/permission-system.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 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { | ||
ContentPermission, | ||
GeneralPermission, | ||
IPermissionSystem, | ||
IUser, | ||
TemporaryFilePermission, | ||
UserDataPermission, | ||
} from '@lumieducation/h5p-server'; | ||
|
||
export default class PermissionSystem implements IPermissionSystem<IUser> { | ||
checkForUserData( | ||
actingUser: IUser, | ||
permission: UserDataPermission, | ||
contentId: string, | ||
affectedUserId?: string | ||
): Promise<boolean> { | ||
return Promise.resolve(true); | ||
} | ||
|
||
async checkForContent( | ||
actingUser: IUser | undefined, | ||
permission: ContentPermission, | ||
contentId?: string | ||
): Promise<boolean> { | ||
return Promise.resolve(true); | ||
} | ||
|
||
async checkForTemporaryFile( | ||
user: IUser | undefined, | ||
permission: TemporaryFilePermission, | ||
filename?: string | ||
): Promise<boolean> { | ||
return Promise.resolve(true); | ||
} | ||
|
||
async checkForGeneralAction(actingUser: IUser | undefined, permission: GeneralPermission): Promise<boolean> { | ||
return Promise.resolve(true); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,20 +1,21 @@ | ||
import { | ||
H5PConfig, | ||
cacheImplementations, | ||
LibraryManager, | ||
ContentTypeCache, | ||
H5PConfig, | ||
ILibraryAdministrationOverviewItem, | ||
IUser, | ||
LibraryAdministration, | ||
ILibraryAdministrationOverviewItem, | ||
LibraryManager, | ||
} from '@lumieducation/h5p-server'; | ||
import ContentManager from '@lumieducation/h5p-server/build/src/ContentManager'; | ||
import ContentTypeInformationRepository from '@lumieducation/h5p-server/build/src/ContentTypeInformationRepository'; | ||
import { IHubContentType } from '@lumieducation/h5p-server/build/src/types'; | ||
import { Injectable, InternalServerErrorException, NotFoundException } from '@nestjs/common'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { ContentStorage, LibraryStorage } from '@src/modules/h5p-editor'; | ||
import { readFileSync } from 'fs'; | ||
import { parse } from 'yaml'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { IHubContentType } from '@lumieducation/h5p-server/build/src/types'; | ||
import PermissionSystem from '../permission-system'; | ||
import { IH5PLibraryManagementConfig } from './h5p-library-management.config'; | ||
|
||
const h5pConfig = new H5PConfig(undefined, { | ||
|
@@ -75,8 +76,14 @@ export class H5PLibraryManagementService { | |
undefined, | ||
h5pConfig | ||
); | ||
this.contentTypeRepo = new ContentTypeInformationRepository(this.contentTypeCache, this.libraryManager, h5pConfig); | ||
const contentManager = new ContentManager(this.contentStorage); | ||
const permissionSystem = new PermissionSystem(); | ||
this.contentTypeRepo = new ContentTypeInformationRepository( | ||
this.contentTypeCache, | ||
this.libraryManager, | ||
h5pConfig, | ||
permissionSystem | ||
); | ||
const contentManager = new ContentManager(this.contentStorage, permissionSystem); | ||
this.libraryAdministration = new LibraryAdministration(this.libraryManager, contentManager); | ||
const filePath = this.configService.get<string>('H5P_EDITOR__LIBRARY_LIST_PATH'); | ||
|
||
|
@@ -115,9 +122,6 @@ export class H5PLibraryManagementService { | |
|
||
private createDefaultIUser(): IUser { | ||
const user: IUser = { | ||
canCreateRestricted: true, | ||
canInstallRecommended: true, | ||
canUpdateAndInstallLibraries: true, | ||
email: '[email protected]', | ||
id: 'a', | ||
name: 'a', | ||
|