feat: keep track of page contributors (#959)

* WIP

* feat: store and retrieve page contributors
This commit is contained in:
Philip Okugbe
2025-04-04 13:03:57 +01:00
committed by GitHub
parent 8aa604637e
commit 64f0531093
7 changed files with 82 additions and 7 deletions

View File

@ -46,6 +46,7 @@ export class PageController {
includeContent: true,
includeCreator: true,
includeLastUpdatedBy: true,
includeContributors: true,
});
if (!page) {
@ -93,7 +94,7 @@ export class PageController {
}
return this.pageService.update(
updatePageDto.pageId,
page,
updatePageDto,
user.id,
);

View File

@ -112,21 +112,32 @@ export class PageService {
}
async update(
pageId: string,
page: Page,
updatePageDto: UpdatePageDto,
userId: string,
): Promise<Page> {
const contributors = new Set<string>(page.contributorIds);
contributors.add(userId);
const contributorIds = Array.from(contributors);
await this.pageRepo.updatePage(
{
title: updatePageDto.title,
icon: updatePageDto.icon,
lastUpdatedById: userId,
updatedAt: new Date(),
contributorIds: contributorIds,
},
pageId,
page.id,
);
return await this.pageRepo.findById(pageId);
return await this.pageRepo.findById(page.id, {
includeSpace: true,
includeContent: true,
includeCreator: true,
includeLastUpdatedBy: true,
includeContributors: true,
});
}
withHasChildren(eb: ExpressionBuilder<DB, 'pages'>) {