|
@@ -8,11 +8,11 @@ import {
|
|
|
PageStatus, YDocStatus, getIdForRef,
|
|
PageStatus, YDocStatus, getIdForRef,
|
|
|
getIdStringForRef,
|
|
getIdStringForRef,
|
|
|
} from '@growi/core';
|
|
} from '@growi/core';
|
|
|
-import { PageGrant, isIPageInfoForEntity } from '@growi/core/dist/interfaces';
|
|
|
|
|
|
|
+import { PageGrant, isIPageInfoForEmpty, isIPageInfoForEntity } from '@growi/core/dist/interfaces';
|
|
|
import type {
|
|
import type {
|
|
|
Ref, HasObjectId, IUserHasId, IUser,
|
|
Ref, HasObjectId, IUserHasId, IUser,
|
|
|
IPage, IGrantedGroup, IRevisionHasId,
|
|
IPage, IGrantedGroup, IRevisionHasId,
|
|
|
- IPageNotFoundInfo, IPageInfoExt, IPageInfo, IPageInfoForEntity, IPageInfoForOperation,
|
|
|
|
|
|
|
+ IPageNotFoundInfo, IPageInfoExt, IPageInfo, IPageInfoForEmpty, IPageInfoForEntity, IPageInfoForOperation,
|
|
|
IDataWithRequiredMeta,
|
|
IDataWithRequiredMeta,
|
|
|
} from '@growi/core/dist/interfaces';
|
|
} from '@growi/core/dist/interfaces';
|
|
|
import {
|
|
import {
|
|
@@ -460,7 +460,7 @@ class PageService implements IPageService {
|
|
|
const pageInfo = {
|
|
const pageInfo = {
|
|
|
...basicPageInfo,
|
|
...basicPageInfo,
|
|
|
bookmarkCount,
|
|
bookmarkCount,
|
|
|
- } satisfies IPageInfo | IPageInfoForEntity;
|
|
|
|
|
|
|
+ } satisfies | IPageInfo | IPageInfoForEntity;
|
|
|
|
|
|
|
|
if (isGuestUser) {
|
|
if (isGuestUser) {
|
|
|
return {
|
|
return {
|
|
@@ -475,21 +475,25 @@ class PageService implements IPageService {
|
|
|
|
|
|
|
|
const isDeletable = this.canDelete(page, creatorId, user, false);
|
|
const isDeletable = this.canDelete(page, creatorId, user, false);
|
|
|
const isAbleToDeleteCompletely = this.canDeleteCompletely(page, creatorId, user, false, userRelatedGroups); // use normal delete config
|
|
const isAbleToDeleteCompletely = this.canDeleteCompletely(page, creatorId, user, false, userRelatedGroups); // use normal delete config
|
|
|
|
|
+ const isBookmarked: boolean = isGuestUser
|
|
|
|
|
+ ? false
|
|
|
|
|
+ : (await Bookmark.findByPageIdAndUserId(pageId, user._id)) != null;
|
|
|
|
|
|
|
|
- if (!isIPageInfoForEntity(pageInfo)) {
|
|
|
|
|
|
|
+ if (isIPageInfoForEmpty(pageInfo)) {
|
|
|
return {
|
|
return {
|
|
|
data: page,
|
|
data: page,
|
|
|
meta: {
|
|
meta: {
|
|
|
...pageInfo,
|
|
...pageInfo,
|
|
|
isDeletable,
|
|
isDeletable,
|
|
|
isAbleToDeleteCompletely,
|
|
isAbleToDeleteCompletely,
|
|
|
- } satisfies IPageInfo,
|
|
|
|
|
|
|
+ isBookmarked,
|
|
|
|
|
+ } satisfies IPageInfoForEmpty,
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const isBookmarked: boolean = isGuestUser
|
|
|
|
|
- ? false
|
|
|
|
|
- : (await Bookmark.findByPageIdAndUserId(pageId, user._id)) != null;
|
|
|
|
|
|
|
+ // IPageInfoForEmpty and IPageInfoForEntity are mutually exclusive
|
|
|
|
|
+ // so hereafter we can safely
|
|
|
|
|
+ assert(isIPageInfoForEntity(pageInfo));
|
|
|
|
|
|
|
|
const isLiked: boolean = page.isLiked(user);
|
|
const isLiked: boolean = page.isLiked(user);
|
|
|
const subscription = await Subscription.findByUserIdAndTargetId(user._id, page._id);
|
|
const subscription = await Subscription.findByUserIdAndTargetId(user._id, page._id);
|
|
@@ -2578,7 +2582,7 @@ class PageService implements IPageService {
|
|
|
isV5Compatible: true,
|
|
isV5Compatible: true,
|
|
|
isEmpty: true,
|
|
isEmpty: true,
|
|
|
isMovable,
|
|
isMovable,
|
|
|
- isDeletable: false,
|
|
|
|
|
|
|
+ isDeletable,
|
|
|
isAbleToDeleteCompletely: false,
|
|
isAbleToDeleteCompletely: false,
|
|
|
isRevertible: false,
|
|
isRevertible: false,
|
|
|
};
|
|
};
|