user health no err

This commit is contained in:
boufni95 2024-12-12 18:59:25 +00:00
parent 84b3ef4b9d
commit 93af9969ed
11 changed files with 234 additions and 192 deletions

View file

@ -701,14 +701,17 @@ export default (params: NostrClientParams, send: (to:string, message: NostrRequ
}
return { status: 'ERROR', reason: 'invalid response' }
},
UserHealth: async (): Promise<ResultError | ({ status: 'OK' })> => {
UserHealth: async (): Promise<ResultError | ({ status: 'OK' }& Types.UserHealthState)> => {
const auth = await params.retrieveNostrUserAuth()
if (auth === null) throw new Error('retrieveNostrUserAuth() returned null')
const nostrRequest: NostrRequest = {}
const data = await send(params.pubDestination, {rpcName:'UserHealth',authIdentifier:auth, ...nostrRequest })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
return data
const result = data
if(!params.checkResult) return { status: 'OK', ...result }
const error = Types.UserHealthStateValidate(result)
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
}
return { status: 'ERROR', reason: 'invalid response' }
},