chore: fix ContentType usage (#2353)

* chore: fix ContentType usage

* chore: fix specs
This commit is contained in:
Karol Sójko
2023-07-12 13:53:29 +02:00
committed by GitHub
parent d057cdff84
commit 325737bfbd
247 changed files with 1092 additions and 1060 deletions

View File

@@ -1,4 +1,3 @@
import { ContentType } from '@standardnotes/common'
import { ItemsKeyInterface } from '@standardnotes/models'
import { dateSorted } from '@standardnotes/utils'
import { SNRootKeyParams, EncryptionProviderInterface } from '@standardnotes/encryption'
@@ -6,6 +5,7 @@ import { DecryptionQueueItem, KeyRecoveryOperationResult } from './Types'
import { serverKeyParamsAreSafe } from './Utils'
import { ChallengeServiceInterface, DecryptItemsKeyByPromptingUser } from '@standardnotes/services'
import { ItemManager } from '../Items'
import { ContentType } from '@standardnotes/domain-core'
export class KeyRecoveryOperation {
constructor(
@@ -29,7 +29,7 @@ export class KeyRecoveryOperation {
if (queueItemKeyParamsAreBetterOrEqualToClients) {
const latestDecryptedItemsKey = dateSorted(
this.itemManager.getItems<ItemsKeyInterface>(ContentType.ItemsKey),
this.itemManager.getItems<ItemsKeyInterface>(ContentType.TYPES.ItemsKey),
'created_at',
false,
)[0]

View File

@@ -16,7 +16,6 @@ import { DiskStorageService } from '../Storage/DiskStorageService'
import { PayloadManager } from '../Payloads/PayloadManager'
import { ChallengeService } from '../Challenge'
import { SNApiService } from '@Lib/Services/Api/ApiService'
import { ContentType } from '@standardnotes/common'
import { ItemManager } from '../Items/ItemManager'
import { removeFromArray, Uuids } from '@standardnotes/utils'
import { ClientDisplayableError, isErrorResponse } from '@standardnotes/responses'
@@ -43,6 +42,7 @@ import {
KeyRecoveryOperationResult,
} from './Types'
import { serverKeyParamsAreSafe } from './Utils'
import { ContentType } from '@standardnotes/domain-core'
/**
* The key recovery service listens to items key changes to detect any that cannot be decrypted.
@@ -99,7 +99,7 @@ export class SNKeyRecoveryService extends AbstractService<KeyRecoveryEvent, Decr
super(internalEventBus)
this.removeItemObserver = this.payloadManager.addObserver(
[ContentType.ItemsKey],
[ContentType.TYPES.ItemsKey],
({ changed, inserted, ignored, source }) => {
if (source === PayloadEmitSource.LocalChanged) {
return
@@ -181,7 +181,7 @@ export class SNKeyRecoveryService extends AbstractService<KeyRecoveryEvent, Decr
public presentKeyRecoveryWizard(): void {
const invalidKeys = this.itemManager.invalidItems
.filter((i) => i.content_type === ContentType.ItemsKey)
.filter((i) => i.content_type === ContentType.TYPES.ItemsKey)
.map((i) => i.payload)
void this.handleIgnoredItemsKeys(invalidKeys, false)