Skip to content

Commit e77a599

Browse files
committed
feat: add nip45.enabled test and docs
1 parent f6ad1bd commit e77a599

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

CONFIGURATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ The settings below are listed in alphabetical order by name. Please keep this ta
163163
| nip05.mode | NIP-05 verification mode: `enabled` requires verification, `passive` verifies without blocking, `disabled` does nothing. Defaults to `disabled`. |
164164
| nip05.verifyExpiration | Time in milliseconds before a successful NIP-05 verification expires and needs re-checking. Defaults to 604800000 (1 week). |
165165
| nip05.verifyUpdateFrequency | Minimum interval in milliseconds between re-verification attempts for a given author. Defaults to 86400000 (24 hours). |
166+
| nip45.enabled | Enable or disable NIP-45 COUNT handling. Defaults to true. |
166167
| paymentProcessors.lnbits.baseURL | Base URL of your Lnbits instance. |
167168
| paymentProcessors.lnbits.callbackBaseURL | Public-facing Nostream's Lnbits Callback URL. (e.g. https://relay.your-domain.com/callbacks/lnbits) |
168169
| paymentProcessors.lnurl.invoiceURL | [LUD-06 Pay Request](https://github.com/lnurl/luds/blob/luds/06.md) provider URL. (e.g. https://getalby.com/lnurlp/your-username) |

src/repositories/event-repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class EventRepository implements IEventRepository {
9595
}
9696

9797
public async countByFilters(filters: SubscriptionFilter[]): Promise<number> {
98-
debug('counting events for %o', filters)
98+
logger('counting events for %o', filters)
9999

100100
if (!Array.isArray(filters) || !filters.length) {
101101
throw new Error('Filters cannot be empty')

test/unit/handlers/count-message-handler.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,20 @@ describe('CountMessageHandler', () => {
129129
'error: unable to count events',
130130
])
131131
})
132+
133+
it('returns CLOSED when COUNT is disabled in settings', async () => {
134+
handler = new CountMessageHandler(webSocket, eventRepository, () => ({ nip45: { enabled: false } }) as Settings)
135+
136+
const message = [MessageType.COUNT, 'q1', {}] as any
137+
138+
await handler.handleMessage(message)
139+
140+
expect(eventRepository.countByFilters).to.not.have.been.called
141+
expect(webSocketOnMessageStub).to.have.been.calledOnceWithExactly([
142+
MessageType.CLOSED,
143+
'q1',
144+
'COUNT is disabled by relay configuration',
145+
])
146+
})
132147
})
133148
})

0 commit comments

Comments
 (0)