damus icon indicating copy to clipboard operation
damus copied to clipboard

delete like

Open githubbbie opened this issue 2 years ago • 3 comments

githubbbie avatar Dec 17 '22 03:12 githubbbie

@jb55

To add a like, you are appending the id and pubkey to tags and passing it, to delete a like, we get the tags and remove the previously added like id and pubkey from the array and push the update? Or its a completely different way of doing it?

func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent {
    var tags: [[String]] = liked.tags.filter { tag in tag.count >= 2 && (tag[0] == "e" || tag[0] == "p") }
    tags.append(["e", liked.id])
    tags.append(["p", liked.pubkey])
    debugPrint("like event", liked)
    let ev = NostrEvent(content: "", pubkey: pubkey, kind: 7, tags: tags)
    ev.calculate_id()
    ev.sign(privkey: privkey)

    return ev
}

niteshbalusu11 avatar Dec 21 '22 06:12 niteshbalusu11

Like deletion is implemented in Damus web, its just a kind5 note referencing the original like

jb55 avatar Dec 23 '22 13:12 jb55

Also see #387

jblachly avatar Jan 27 '23 16:01 jblachly