add amber decrypt mutes

This commit is contained in:
Believethehype
2024-04-29 21:22:36 +02:00
parent e484f612f0
commit 8eb0d4c1fd
3 changed files with 38 additions and 19 deletions

View File

@@ -19,7 +19,7 @@
"bootstrap": "^5.3.2",
"daisyui": "^4.6.0",
"mini-toastr": "^0.8.1",
"nostr-login": "^1.1.1",
"nostr-login": "^1.3.0",
"nostr-tools": "^2.4.0",
"vue": "^3.4.15",
"vue-notifications": "^1.0.2",

View File

@@ -925,6 +925,7 @@ async function mute_all(results){
let newcontent = JSON.stringify(jsonObject)
console.log(newcontent)
let lol = "[]"
eventasjson.content = await (await signer).nip04Encrypt(store.state.pubkey, newcontent)
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)
if (mutes.length > 0) {
let list = mutes[0]
let id = list.id.toHex()
let content = ""
try {
let eventasjson = JSON.parse(list.asJson())
let content = await (await signer).nip04Decrypt(store.state.pubkey, list.content)
let jsonObject = JSON.parse(content)
console.log(content)
try{
console.log(list.content)
let signer = await store.state.signer
content = await signer.nip04Decrypt(store.state.pubkey, list.content)
console.log(content)
}
catch(error){
console.log(error)
}
let jsonObject = JSON.parse(content)
let exists = false
for(let i = 0; i < jsonObject.length; i++)
{
@@ -982,7 +992,7 @@ async function mute(result) {
store.state.mutes.push(result.authorid)
let newcontent = JSON.stringify(jsonObject)
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)
try{

View File

@@ -189,7 +189,7 @@ import {
Options,
Duration,
PublicKey,
Nip46Signer, NegentropyDirection, NegentropyOptions, NostrSigner, RelayLimits, Contact
Nip46Signer, NegentropyDirection, NegentropyOptions, NostrSigner, RelayLimits, Contact, Event
} from "@rust-nostr/nostr-sdk";
import VueNotifications from "vue-notifications";
import store from '../store';
@@ -330,9 +330,9 @@ export default {
}
if (e.detail.type === "logout") {
await this.sign_out()
/*await this.sign_out()
//await this.state.client.shutdown()G;
await this.sign_in_anon()
await this.sign_in_anon() */
console.log("Logged out")
}
},
@@ -940,22 +940,31 @@ export default {
for (let list of mutes){
let client = store.state.client
let signer = client.signer()
for (let tag of list.tags){
if (tag.asVec()[0] === "p"){
//console.log(tag.asVec()[1])
mutelist.push(tag.asVec()[1])
for (let tag of list.tags){
if (tag.asVec()[0] === "p"){
//console.log(tag.asVec()[1])
mutelist.push(tag.asVec()[1])
}
}
}
console.log("Public mutes: " + mutelist.length)
//private mutes
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)
for (let entry of json) {
if (entry[0] === "p") {
@@ -969,7 +978,7 @@ export default {
//console.log(error)
}
}
console.log("Overall mutes: " + mutelist.length)
}
store.commit('set_mutes', mutelist)