mirror of
https://github.com/standardnotes/server
synced 2026-07-14 00:01:54 -04:00
Revert "tmp: disable decorating items completely"
This reverts commit bc1c7a8ae1.
This commit is contained in:
@@ -139,7 +139,7 @@ export class ExtensionsHttpService implements ExtensionsHttpServiceInterface {
|
||||
userUuid: string,
|
||||
email: string,
|
||||
): Promise<DomainEventInterface> {
|
||||
const extension = await this.itemRepository.findByUuidAndUserUuid(extensionId, userUuid, true)
|
||||
const extension = await this.itemRepository.findByUuidAndUserUuid(extensionId, userUuid)
|
||||
if (extension === null || !extension.props.content) {
|
||||
throw Error(`Could not find extensions with id ${extensionId}`)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ export class DuplicateItemSyncedEventHandler implements DomainEventHandlerInterf
|
||||
) {}
|
||||
|
||||
async handle(event: DuplicateItemSyncedEvent): Promise<void> {
|
||||
const item = await this.itemRepository.findByUuidAndUserUuid(event.payload.itemUuid, event.payload.userUuid, true)
|
||||
const item = await this.itemRepository.findByUuidAndUserUuid(event.payload.itemUuid, event.payload.userUuid)
|
||||
|
||||
if (item === null) {
|
||||
this.logger.warn(`Could not find item with uuid ${event.payload.itemUuid}`)
|
||||
@@ -33,7 +33,6 @@ export class DuplicateItemSyncedEventHandler implements DomainEventHandlerInterf
|
||||
const existingOriginalItem = await this.itemRepository.findByUuidAndUserUuid(
|
||||
item.props.duplicateOf.value,
|
||||
event.payload.userUuid,
|
||||
true,
|
||||
)
|
||||
|
||||
if (existingOriginalItem !== null) {
|
||||
|
||||
@@ -53,14 +53,11 @@ export class EmailBackupRequestedEventHandler implements DomainEventHandlerInter
|
||||
|
||||
const backupFileNames: string[] = []
|
||||
for (const itemUuidBundle of itemUuidBundles) {
|
||||
const items = await this.itemRepository.findAll(
|
||||
{
|
||||
uuids: itemUuidBundle,
|
||||
sortBy: 'updated_at_timestamp',
|
||||
sortOrder: 'ASC',
|
||||
},
|
||||
true,
|
||||
)
|
||||
const items = await this.itemRepository.findAll({
|
||||
uuids: itemUuidBundle,
|
||||
sortBy: 'updated_at_timestamp',
|
||||
sortOrder: 'ASC',
|
||||
})
|
||||
|
||||
const bundleBackupFileNames = await this.itemBackupService.backup(
|
||||
items,
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ExtendedIntegrityPayload } from './ExtendedIntegrityPayload'
|
||||
|
||||
export interface ItemRepositoryInterface {
|
||||
deleteByUserUuid(userUuid: string): Promise<void>
|
||||
findAll(query: ItemQuery, noAssociations: boolean): Promise<Item[]>
|
||||
findAll(query: ItemQuery): Promise<Item[]>
|
||||
findAllRaw<T>(query: ItemQuery): Promise<T[]>
|
||||
streamAll(query: ItemQuery): Promise<ReadStream>
|
||||
countAll(query: ItemQuery): Promise<number>
|
||||
@@ -16,7 +16,7 @@ export interface ItemRepositoryInterface {
|
||||
): Promise<Array<{ uuid: string; contentSize: number | null }>>
|
||||
findDatesForComputingIntegrityHash(userUuid: string): Promise<Array<{ updated_at_timestamp: number }>>
|
||||
findItemsForComputingIntegrityPayloads(userUuid: string): Promise<ExtendedIntegrityPayload[]>
|
||||
findByUuidAndUserUuid(uuid: string, userUuid: string, noAssociations: boolean): Promise<Item | null>
|
||||
findByUuidAndUserUuid(uuid: string, userUuid: string): Promise<Item | null>
|
||||
findByUuid(uuid: Uuid, noAssociations: boolean): Promise<Item | null>
|
||||
remove(item: Item): Promise<void>
|
||||
save(item: Item): Promise<void>
|
||||
|
||||
@@ -8,7 +8,7 @@ export class GetItem implements UseCaseInterface<Item> {
|
||||
constructor(private itemRepository: ItemRepositoryInterface) {}
|
||||
|
||||
async execute(dto: GetItemDTO): Promise<Result<Item>> {
|
||||
const item = await this.itemRepository.findByUuidAndUserUuid(dto.itemUuid, dto.userUuid, true)
|
||||
const item = await this.itemRepository.findByUuidAndUserUuid(dto.itemUuid, dto.userUuid)
|
||||
|
||||
if (item === null) {
|
||||
return Result.fail(`Could not find item with uuid ${dto.itemUuid}`)
|
||||
|
||||
@@ -56,14 +56,11 @@ export class GetItems implements UseCaseInterface<GetItemsResult> {
|
||||
)
|
||||
let items: Array<Item> = []
|
||||
if (itemUuidsToFetch.length > 0) {
|
||||
items = await this.itemRepository.findAll(
|
||||
{
|
||||
uuids: itemUuidsToFetch,
|
||||
sortBy: 'updated_at_timestamp',
|
||||
sortOrder: 'ASC',
|
||||
},
|
||||
true,
|
||||
)
|
||||
items = await this.itemRepository.findAll({
|
||||
uuids: itemUuidsToFetch,
|
||||
sortBy: 'updated_at_timestamp',
|
||||
sortOrder: 'ASC',
|
||||
})
|
||||
}
|
||||
const totalItemsCount = await this.itemRepository.countAll(itemQuery)
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ export class SaveItems implements UseCaseInterface<SaveItemsResult> {
|
||||
}
|
||||
const itemUuid = itemUuidOrError.getValue()
|
||||
|
||||
const existingItem = await this.itemRepository.findByUuid(itemUuid, true)
|
||||
const existingItem = await this.itemRepository.findByUuid(itemUuid, false)
|
||||
|
||||
if (dto.readOnlyAccess) {
|
||||
conflicts.push({
|
||||
|
||||
@@ -126,15 +126,12 @@ export class SyncItems implements UseCaseInterface<SyncItemsResponse> {
|
||||
}
|
||||
|
||||
private async frontLoadKeysItemsToTop(userUuid: string, retrievedItems: Array<Item>): Promise<Array<Item>> {
|
||||
const itemsKeys = await this.itemRepository.findAll(
|
||||
{
|
||||
userUuid,
|
||||
contentType: ContentType.TYPES.ItemsKey,
|
||||
sortBy: 'updated_at_timestamp',
|
||||
sortOrder: 'ASC',
|
||||
},
|
||||
true,
|
||||
)
|
||||
const itemsKeys = await this.itemRepository.findAll({
|
||||
userUuid,
|
||||
contentType: ContentType.TYPES.ItemsKey,
|
||||
sortBy: 'updated_at_timestamp',
|
||||
sortOrder: 'ASC',
|
||||
})
|
||||
|
||||
const retrievedItemsIds: Array<string> = retrievedItems.map((item: Item) => item.id.toString())
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ export class TypeORMItemRepository implements ItemRepositoryInterface {
|
||||
return items.sort((itemA, itemB) => itemB.updated_at_timestamp - itemA.updated_at_timestamp)
|
||||
}
|
||||
|
||||
async findByUuidAndUserUuid(uuid: string, userUuid: string, noAssociations: boolean): Promise<Item | null> {
|
||||
async findByUuidAndUserUuid(uuid: string, userUuid: string): Promise<Item | null> {
|
||||
const persistence = await this.ormRepository
|
||||
.createQueryBuilder('item')
|
||||
.where('item.uuid = :uuid AND item.user_uuid = :userUuid', {
|
||||
@@ -146,10 +146,6 @@ export class TypeORMItemRepository implements ItemRepositoryInterface {
|
||||
try {
|
||||
const item = this.mapper.toDomain(persistence)
|
||||
|
||||
if (noAssociations) {
|
||||
return item
|
||||
}
|
||||
|
||||
await this.decorateItemWithAssociations(item)
|
||||
|
||||
return item
|
||||
@@ -160,7 +156,7 @@ export class TypeORMItemRepository implements ItemRepositoryInterface {
|
||||
}
|
||||
}
|
||||
|
||||
async findAll(query: ItemQuery, noAssociations: boolean): Promise<Item[]> {
|
||||
async findAll(query: ItemQuery): Promise<Item[]> {
|
||||
const persistence = await this.createFindAllQueryBuilder(query).getMany()
|
||||
|
||||
const domainItems: Item[] = []
|
||||
@@ -172,10 +168,6 @@ export class TypeORMItemRepository implements ItemRepositoryInterface {
|
||||
}
|
||||
}
|
||||
|
||||
if (noAssociations) {
|
||||
return domainItems
|
||||
}
|
||||
|
||||
await Promise.all(domainItems.map((item) => this.decorateItemWithAssociations(item)))
|
||||
|
||||
return domainItems
|
||||
|
||||
Reference in New Issue
Block a user