Skip to content

Commit

Permalink
fix: blocked/block => denied/deny
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine committed Nov 1, 2023
1 parent 780071a commit 1c6576f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
24 changes: 12 additions & 12 deletions src/Contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
fromNanoString,
} from './utils'

export type ConsentState = 'allowed' | 'blocked' | 'unknown'
export type ConsentState = 'allowed' | 'denied' | 'unknown'

export type ConsentListEntryType = 'address'

Expand Down Expand Up @@ -54,9 +54,9 @@ export class ConsentList {
return entry
}

block(address: string) {
const entry = ConsentListEntry.fromAddress(address, 'blocked')
this.entries.set(entry.key, 'blocked')
deny(address: string) {
const entry = ConsentListEntry.fromAddress(address, 'denied')
this.entries.set(entry.key, 'denied')
return entry
}

Expand Down Expand Up @@ -120,7 +120,7 @@ export class ConsentList {
this.allow(address)
})
action.block?.walletAddresses.forEach((address) => {
this.block(address)
this.deny(address)
})
})

Expand All @@ -144,7 +144,7 @@ export class ConsentList {
}
: undefined,
block:
entry.permissionType === 'blocked'
entry.permissionType === 'denied'
? {
walletAddresses: [entry.value],
}
Expand Down Expand Up @@ -229,8 +229,8 @@ export class Contacts {
if (entry.permissionType === 'allowed') {
this.consentList.allow(entry.value)
}
if (entry.permissionType === 'blocked') {
this.consentList.block(entry.value)
if (entry.permissionType === 'denied') {
this.consentList.deny(entry.value)
}
})
}
Expand All @@ -239,8 +239,8 @@ export class Contacts {
return this.consentList.state(address) === 'allowed'
}

isBlocked(address: string) {
return this.consentList.state(address) === 'blocked'
isDenied(address: string) {
return this.consentList.state(address) === 'denied'
}

consentState(address: string) {
Expand All @@ -255,10 +255,10 @@ export class Contacts {
)
}

async block(addresses: string[]) {
async deny(addresses: string[]) {
await this.consentList.publish(
addresses.map((address) =>
ConsentListEntry.fromAddress(address, 'blocked')
ConsentListEntry.fromAddress(address, 'denied')
)
)
}
Expand Down
24 changes: 12 additions & 12 deletions src/conversations/Conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ export interface Conversation<ContentTypes = any> {
*/
allow(): Promise<void>
/**
* Add conversation peer address to block list
* Add conversation peer address to deny list
*/
block(): Promise<void>
deny(): Promise<void>

/**
* Returns true if conversation peer address is on the allow list
*/
isAllowed: boolean
/**
* Returns true if conversation peer address is on the block list
* Returns true if conversation peer address is on the deny list
*/
isBlocked: boolean
isDenied: boolean
/**
* Returns the consent state of the conversation peer address
*/
Expand Down Expand Up @@ -191,16 +191,16 @@ export class ConversationV1<ContentTypes>
await this.client.contacts.allow([this.peerAddress])
}

async block() {
await this.client.contacts.block([this.peerAddress])
async deny() {
await this.client.contacts.deny([this.peerAddress])
}

get isAllowed() {
return this.client.contacts.isAllowed(this.peerAddress)
}

get isBlocked() {
return this.client.contacts.isBlocked(this.peerAddress)
get isDenied() {
return this.client.contacts.isDenied(this.peerAddress)
}

get consentState() {
Expand Down Expand Up @@ -522,16 +522,16 @@ export class ConversationV2<ContentTypes>
await this.client.contacts.allow([this.peerAddress])
}

async block() {
await this.client.contacts.block([this.peerAddress])
async deny() {
await this.client.contacts.deny([this.peerAddress])
}

get isAllowed() {
return this.client.contacts.isAllowed(this.peerAddress)
}

get isBlocked() {
return this.client.contacts.isBlocked(this.peerAddress)
get isDenied() {
return this.client.contacts.isDenied(this.peerAddress)
}

get consentState() {
Expand Down

0 comments on commit 1c6576f

Please sign in to comment.