commit 571ed39d52813488a978bb57ee0f74a978762897
parent 16d81ed40fc03145b7dd91838b98134d6ecd1ead
Author: William Casarin <jb55@jb55.com>
Date: Sun, 16 Jul 2023 14:58:20 -0700
Fixed issue where hashtags were leaking in DMs
Now we never add any tags to DMs, we only add the p tag of the user
you're talking to.
Changelog-Fixed: Fixed issue where hashtags were leaking in DMs
Diffstat:
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/damus/Models/Mentions.swift b/damus/Models/Mentions.swift
@@ -438,15 +438,14 @@ func parse_mention_type(_ c: String) -> MentionType? {
}
/// Convert
-func make_post_tags(post_blocks: [Block], tags: [[String]], silent_mentions: Bool) -> PostTags {
+func make_post_tags(post_blocks: [Block], tags: [[String]]) -> PostTags {
var new_tags = tags
for post_block in post_blocks {
switch post_block {
case .mention(let mention):
let mention_type = mention.type
-
- if silent_mentions || mention_type == .event {
+ if mention_type == .event {
continue
}
@@ -468,7 +467,7 @@ func make_post_tags(post_blocks: [Block], tags: [[String]], silent_mentions: Boo
func post_to_event(post: NostrPost, privkey: String, pubkey: String) -> NostrEvent {
let tags = post.references.map(refid_to_tag) + post.tags
let post_blocks = parse_post_blocks(content: post.content)
- let post_tags = make_post_tags(post_blocks: post_blocks, tags: tags, silent_mentions: false)
+ let post_tags = make_post_tags(post_blocks: post_blocks, tags: tags)
let content = render_blocks(blocks: post_tags.blocks)
let new_ev = NostrEvent(content: content, pubkey: pubkey, kind: post.kind.rawValue, tags: post_tags.tags)
new_ev.calculate_id()
diff --git a/damus/Views/DMChatView.swift b/damus/Views/DMChatView.swift
@@ -130,10 +130,9 @@ struct DMChatView: View, KeyboardReadable {
func send_message() {
let tags = [["p", pubkey]]
let post_blocks = parse_post_blocks(content: dms.draft)
- let post_tags = make_post_tags(post_blocks: post_blocks, tags: tags, silent_mentions: true)
- let content = render_blocks(blocks: post_tags.blocks)
-
- guard let dm = create_dm(content, to_pk: pubkey, tags: post_tags.tags, keypair: damus_state.keypair) else {
+ let content = render_blocks(blocks: post_blocks)
+
+ guard let dm = create_dm(content, to_pk: pubkey, tags: tags, keypair: damus_state.keypair) else {
print("error creating dm")
return
}