mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-10-05 21:52:28 +02:00
add amber decrypt mutes
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
"bootstrap": "^5.3.2",
|
"bootstrap": "^5.3.2",
|
||||||
"daisyui": "^4.6.0",
|
"daisyui": "^4.6.0",
|
||||||
"mini-toastr": "^0.8.1",
|
"mini-toastr": "^0.8.1",
|
||||||
"nostr-login": "^1.1.1",
|
"nostr-login": "^1.3.0",
|
||||||
"nostr-tools": "^2.4.0",
|
"nostr-tools": "^2.4.0",
|
||||||
"vue": "^3.4.15",
|
"vue": "^3.4.15",
|
||||||
"vue-notifications": "^1.0.2",
|
"vue-notifications": "^1.0.2",
|
||||||
|
@@ -925,6 +925,7 @@ async function mute_all(results){
|
|||||||
|
|
||||||
let newcontent = JSON.stringify(jsonObject)
|
let newcontent = JSON.stringify(jsonObject)
|
||||||
console.log(newcontent)
|
console.log(newcontent)
|
||||||
|
let lol = "[]"
|
||||||
eventasjson.content = await (await signer).nip04Encrypt(store.state.pubkey, newcontent)
|
eventasjson.content = await (await signer).nip04Encrypt(store.state.pubkey, newcontent)
|
||||||
let newList = new EventBuilder(list.kind, eventasjson.content, list.tags).toUnsignedEvent(store.state.pubkey)
|
let newList = new EventBuilder(list.kind, eventasjson.content, list.tags).toUnsignedEvent(store.state.pubkey)
|
||||||
|
|
||||||
@@ -959,12 +960,21 @@ async function mute(result) {
|
|||||||
console.log(mutes.length)
|
console.log(mutes.length)
|
||||||
if (mutes.length > 0) {
|
if (mutes.length > 0) {
|
||||||
let list = mutes[0]
|
let list = mutes[0]
|
||||||
let id = list.id.toHex()
|
let content = ""
|
||||||
try {
|
try {
|
||||||
let eventasjson = JSON.parse(list.asJson())
|
let eventasjson = JSON.parse(list.asJson())
|
||||||
let content = await (await signer).nip04Decrypt(store.state.pubkey, list.content)
|
try{
|
||||||
let jsonObject = JSON.parse(content)
|
console.log(list.content)
|
||||||
|
let signer = await store.state.signer
|
||||||
|
content = await signer.nip04Decrypt(store.state.pubkey, list.content)
|
||||||
console.log(content)
|
console.log(content)
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(error){
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
let jsonObject = JSON.parse(content)
|
||||||
let exists = false
|
let exists = false
|
||||||
for(let i = 0; i < jsonObject.length; i++)
|
for(let i = 0; i < jsonObject.length; i++)
|
||||||
{
|
{
|
||||||
@@ -982,7 +992,7 @@ async function mute(result) {
|
|||||||
store.state.mutes.push(result.authorid)
|
store.state.mutes.push(result.authorid)
|
||||||
let newcontent = JSON.stringify(jsonObject)
|
let newcontent = JSON.stringify(jsonObject)
|
||||||
console.log(newcontent)
|
console.log(newcontent)
|
||||||
eventasjson.content = await (await signer).nip04Encrypt(store.state.pubkey, newcontent)
|
eventasjson.content = await store.state.signer.nip04Encrypt(store.state.pubkey, newcontent)
|
||||||
let newList = new EventBuilder(list.kind, eventasjson.content, list.tags).toUnsignedEvent(store.state.pubkey)
|
let newList = new EventBuilder(list.kind, eventasjson.content, list.tags).toUnsignedEvent(store.state.pubkey)
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
@@ -189,7 +189,7 @@ import {
|
|||||||
Options,
|
Options,
|
||||||
Duration,
|
Duration,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
Nip46Signer, NegentropyDirection, NegentropyOptions, NostrSigner, RelayLimits, Contact
|
Nip46Signer, NegentropyDirection, NegentropyOptions, NostrSigner, RelayLimits, Contact, Event
|
||||||
} from "@rust-nostr/nostr-sdk";
|
} from "@rust-nostr/nostr-sdk";
|
||||||
import VueNotifications from "vue-notifications";
|
import VueNotifications from "vue-notifications";
|
||||||
import store from '../store';
|
import store from '../store';
|
||||||
@@ -330,9 +330,9 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (e.detail.type === "logout") {
|
if (e.detail.type === "logout") {
|
||||||
await this.sign_out()
|
/*await this.sign_out()
|
||||||
//await this.state.client.shutdown()G;
|
//await this.state.client.shutdown()G;
|
||||||
await this.sign_in_anon()
|
await this.sign_in_anon() */
|
||||||
console.log("Logged out")
|
console.log("Logged out")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -940,8 +940,6 @@ export default {
|
|||||||
|
|
||||||
for (let list of mutes){
|
for (let list of mutes){
|
||||||
|
|
||||||
let client = store.state.client
|
|
||||||
let signer = client.signer()
|
|
||||||
|
|
||||||
for (let tag of list.tags){
|
for (let tag of list.tags){
|
||||||
if (tag.asVec()[0] === "p"){
|
if (tag.asVec()[0] === "p"){
|
||||||
@@ -949,13 +947,24 @@ export default {
|
|||||||
mutelist.push(tag.asVec()[1])
|
mutelist.push(tag.asVec()[1])
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
console.log("Public mutes: " + mutelist.length)
|
console.log("Public mutes: " + mutelist.length)
|
||||||
|
|
||||||
//private mutes
|
//private mutes
|
||||||
try {
|
try {
|
||||||
let content = await (await signer).nip04Decrypt(store.state.pubkey, list.content)
|
let content = ""
|
||||||
|
console.log(store.state.pubkey.toHex())
|
||||||
|
console.log(list.content)
|
||||||
|
if (localStorage.getItem('nostr-key-method') === 'android-signer') {
|
||||||
|
content = await amberSignerService.nip04Decrypt(store.state.pubkey.toHex(), list.content)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
content = await this.signer.nip04Decrypt(store.state.pubkey, list.content)
|
||||||
|
console.log(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let json = JSON.parse(content)
|
let json = JSON.parse(content)
|
||||||
for (let entry of json) {
|
for (let entry of json) {
|
||||||
if (entry[0] === "p") {
|
if (entry[0] === "p") {
|
||||||
@@ -969,7 +978,7 @@ export default {
|
|||||||
//console.log(error)
|
//console.log(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
console.log("Overall mutes: " + mutelist.length)
|
console.log("Overall mutes: " + mutelist.length)
|
||||||
}
|
}
|
||||||
store.commit('set_mutes', mutelist)
|
store.commit('set_mutes', mutelist)
|
||||||
|
Reference in New Issue
Block a user