chore: fix ContentType usage (#2353)
* chore: fix ContentType usage * chore: fix specs
This commit is contained in:
@@ -15,7 +15,6 @@ import {
|
||||
TrustedContactMutator,
|
||||
DecryptedItemInterface,
|
||||
} from '@standardnotes/models'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { SyncServiceInterface } from '../Sync/SyncServiceInterface'
|
||||
import { ItemManagerInterface } from '../Item/ItemManagerInterface'
|
||||
@@ -31,6 +30,7 @@ import { FindTrustedContactUseCase } from './UseCase/FindTrustedContact'
|
||||
import { SelfContactManager } from './Managers/SelfContactManager'
|
||||
import { CreateOrEditTrustedContactUseCase } from './UseCase/CreateOrEditTrustedContact'
|
||||
import { UpdateTrustedContactUseCase } from './UseCase/UpdateTrustedContact'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class ContactService
|
||||
extends AbstractService<ContactServiceEvent>
|
||||
@@ -191,7 +191,7 @@ export class ContactService
|
||||
})
|
||||
} else {
|
||||
contact = await this.mutator.createItem<TrustedContactInterface>(
|
||||
ContentType.TrustedContact,
|
||||
ContentType.TYPES.TrustedContact,
|
||||
FillItemContent<TrustedContactContent>(data),
|
||||
true,
|
||||
)
|
||||
@@ -224,7 +224,7 @@ export class ContactService
|
||||
}
|
||||
|
||||
getAllContacts(): TrustedContactInterface[] {
|
||||
return this.items.getItems(ContentType.TrustedContact)
|
||||
return this.items.getItems(ContentType.TYPES.TrustedContact)
|
||||
}
|
||||
|
||||
findTrustedContact(userUuid: string): TrustedContactInterface | undefined {
|
||||
|
||||
@@ -15,9 +15,9 @@ import {
|
||||
TrustedContactContentSpecialized,
|
||||
TrustedContactInterface,
|
||||
} from '@standardnotes/models'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { CreateOrEditTrustedContactUseCase } from '../UseCase/CreateOrEditTrustedContact'
|
||||
import { PublicKeySet } from '@standardnotes/encryption'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class SelfContactManager {
|
||||
public selfContact?: TrustedContactInterface
|
||||
@@ -57,7 +57,7 @@ export class SelfContactManager {
|
||||
}
|
||||
|
||||
this.selfContact = this.singletons.findSingleton<TrustedContactInterface>(
|
||||
ContentType.TrustedContact,
|
||||
ContentType.TYPES.TrustedContact,
|
||||
TrustedContact.singletonPredicate,
|
||||
)
|
||||
}
|
||||
@@ -117,7 +117,7 @@ export class SelfContactManager {
|
||||
|
||||
this.selfContact = await this.singletons.findOrCreateSingleton<TrustedContactContent, TrustedContact>(
|
||||
TrustedContact.singletonPredicate,
|
||||
ContentType.TrustedContact,
|
||||
ContentType.TYPES.TrustedContact,
|
||||
FillItemContent<TrustedContactContent>(content),
|
||||
)
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import {
|
||||
} from '@standardnotes/models'
|
||||
import { FindTrustedContactUseCase } from './FindTrustedContact'
|
||||
import { UnknownContactName } from '../UnknownContactName'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { UpdateTrustedContactUseCase } from './UpdateTrustedContact'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class CreateOrEditTrustedContactUseCase {
|
||||
constructor(
|
||||
@@ -49,7 +49,7 @@ export class CreateOrEditTrustedContactUseCase {
|
||||
}
|
||||
|
||||
const contact = await this.mutator.createItem<TrustedContactInterface>(
|
||||
ContentType.TrustedContact,
|
||||
ContentType.TYPES.TrustedContact,
|
||||
FillItemContent<TrustedContactContent>(content),
|
||||
true,
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Predicate, TrustedContactInterface } from '@standardnotes/models'
|
||||
import { ItemManagerInterface } from './../../Item/ItemManagerInterface'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { FindContactQuery } from './FindContactQuery'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class FindTrustedContactUseCase {
|
||||
constructor(private items: ItemManagerInterface) {}
|
||||
@@ -9,18 +9,18 @@ export class FindTrustedContactUseCase {
|
||||
execute(query: FindContactQuery): TrustedContactInterface | undefined {
|
||||
if ('userUuid' in query && query.userUuid) {
|
||||
return this.items.itemsMatchingPredicate<TrustedContactInterface>(
|
||||
ContentType.TrustedContact,
|
||||
ContentType.TYPES.TrustedContact,
|
||||
new Predicate<TrustedContactInterface>('contactUuid', '=', query.userUuid),
|
||||
)[0]
|
||||
}
|
||||
|
||||
if ('signingPublicKey' in query && query.signingPublicKey) {
|
||||
const allContacts = this.items.getItems<TrustedContactInterface>(ContentType.TrustedContact)
|
||||
const allContacts = this.items.getItems<TrustedContactInterface>(ContentType.TYPES.TrustedContact)
|
||||
return allContacts.find((contact) => contact.isSigningKeyTrusted(query.signingPublicKey))
|
||||
}
|
||||
|
||||
if ('publicKey' in query && query.publicKey) {
|
||||
const allContacts = this.items.getItems<TrustedContactInterface>(ContentType.TrustedContact)
|
||||
const allContacts = this.items.getItems<TrustedContactInterface>(ContentType.TYPES.TrustedContact)
|
||||
return allContacts.find((contact) => contact.isPublicKeyTrusted(query.publicKey))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user