mirror of
https://github.com/docmost/docmost.git
synced 2025-11-17 17:21:14 +10:00
Store share key in lowercase
This commit is contained in:
@ -7,7 +7,7 @@ import {
|
||||
import { CreateShareDto, ShareInfoDto, UpdateShareDto } from './dto/share.dto';
|
||||
import { InjectKysely } from 'nestjs-kysely';
|
||||
import { KyselyDB } from '@docmost/db/types/kysely.types';
|
||||
import { generateSlugId } from '../../common/helpers';
|
||||
import { nanoIdGen } from '../../common/helpers';
|
||||
import { PageRepo } from '@docmost/db/repos/page/page.repo';
|
||||
import { TokenService } from '../auth/services/token.service';
|
||||
import { jsonToNode } from '../../collaboration/collaboration.util';
|
||||
@ -66,7 +66,7 @@ export class ShareService {
|
||||
}
|
||||
|
||||
return await this.shareRepo.insertShare({
|
||||
key: generateSlugId(),
|
||||
key: nanoIdGen().toLowerCase(),
|
||||
pageId: page.id,
|
||||
includeSubPages: createShareDto.includeSubPages || true,
|
||||
searchIndexing: createShareDto.searchIndexing || true,
|
||||
@ -224,7 +224,7 @@ export class ShareService {
|
||||
.as('found'),
|
||||
])
|
||||
.where(
|
||||
!isValidUUID(childPageId) ? 'slugId' : 'id',
|
||||
isValidUUID(childPageId) ? 'id' : 'slugId',
|
||||
'=',
|
||||
childPageId,
|
||||
)
|
||||
|
||||
@ -59,7 +59,7 @@ export class ShareRepo {
|
||||
if (isValidUUID(shareId)) {
|
||||
query = query.where('id', '=', shareId);
|
||||
} else {
|
||||
query = query.where('key', '=', shareId);
|
||||
query = query.where(sql`LOWER(key)`, '=', shareId.toLowerCase());
|
||||
}
|
||||
|
||||
return query.executeTakeFirst();
|
||||
@ -98,7 +98,7 @@ export class ShareRepo {
|
||||
return dbOrTx(this.db, trx)
|
||||
.updateTable('shares')
|
||||
.set({ ...updatableShare, updatedAt: new Date() })
|
||||
.where(!isValidUUID(shareId) ? 'key' : 'id', '=', shareId)
|
||||
.where(isValidUUID(shareId) ? 'id' : sql`LOWER(key)`, '=', shareId.toLowerCase())
|
||||
.returning(this.baseFields)
|
||||
.executeTakeFirst();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user