feat: subscribe to DMs

This commit is contained in:
Vlad Stan 2023-05-05 13:58:43 +03:00
parent 58772043d4
commit 81e0aa26f8

View file

@ -210,7 +210,6 @@
v-model="testData.sentData" v-model="testData.sentData"
dense dense
filled filled
readonly
rows="5" rows="5"
type="textarea" type="textarea"
></q-input> ></q-input>
@ -226,7 +225,6 @@
v-model="testData.receivedData" v-model="testData.receivedData"
dense dense
filled filled
readonly
rows="5" rows="5"
type="textarea" type="textarea"
></q-input> ></q-input>
@ -428,6 +426,8 @@
const event = JSON.parse(data.event_json)[1] const event = JSON.parse(data.event_json)[1]
console.log('### event', event) console.log('### event', event)
await this.sendDataToWebSocket(data.event_json) await this.sendDataToWebSocket(data.event_json)
const subscription = JSON.stringify(["REQ", "test-dms", { "kinds": [4], "#p": [event.pubkey]}])
this.testData.wsConnection.send(subscription)
} catch (error) { } catch (error) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
} }
@ -457,8 +457,8 @@
const wsUrl = `${scheme}://${document.domain}${port}/nostrclient/api/v1/relay` const wsUrl = `${scheme}://${document.domain}${port}/nostrclient/api/v1/relay`
this.testData.wsConnection = new WebSocket(wsUrl) this.testData.wsConnection = new WebSocket(wsUrl)
const updateReciveData = async e => { const updateReciveData = async e => {
console.log('### updateReciveData', e.data) const separator = '='.repeat(80)
this.testData.receivedData = e.data + '\n' +this.testData.receivedData this.testData.receivedData = e.data + `\n\n${separator}\n` +this.testData.receivedData
} }
this.testData.wsConnection.onmessage = updateReciveData this.testData.wsConnection.onmessage = updateReciveData