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
This commit is contained in:
William Casarin
2023-07-16 14:58:20 -07:00
parent 16d81ed40f
commit 571ed39d52
2 changed files with 6 additions and 8 deletions

View File

@@ -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()

View File

@@ -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
}