Skip to content

Commit

Permalink
noting: users are now notified when you quote repost them
Browse files Browse the repository at this point in the history
Changelog-Changed: Users are now notified when you quote repost them
  • Loading branch information
jb55 committed Oct 27, 2023
1 parent 4389cc2 commit 7710839
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions damus/Views/PostView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct PostView: View {
}
return true
}
let new_post = build_post(post: self.post, action: action, uploadedMedias: uploadedMedias, references: refs)
let new_post = build_post(state: damus_state, post: self.post, action: action, uploadedMedias: uploadedMedias, references: refs)

notify(.post(.post(new_post)))

Expand Down Expand Up @@ -631,7 +631,7 @@ func load_draft_for_post(drafts: Drafts, action: PostAction) -> DraftArtifacts?
}


func build_post(post: NSMutableAttributedString, action: PostAction, uploadedMedias: [UploadedMedia], references: [RefId]) -> NostrPost {
func build_post(state: DamusState, post: NSMutableAttributedString, action: PostAction, uploadedMedias: [UploadedMedia], references: [RefId]) -> NostrPost {
post.enumerateAttributes(in: NSRange(location: 0, length: post.length), options: []) { attributes, range, stop in
if let link = attributes[.link] as? String {
let normalized_link: String
Expand All @@ -654,15 +654,20 @@ func build_post(post: NSMutableAttributedString, action: PostAction, uploadedMed

let imagesString = uploadedMedias.map { $0.uploadedURL.absoluteString }.joined(separator: " ")

let img_meta_tags = uploadedMedias.compactMap { $0.metadata?.to_tag() }
var tags = uploadedMedias.compactMap { $0.metadata?.to_tag() }

if !imagesString.isEmpty {
content.append(" " + imagesString + " ")
}

if case .quoting(let ev) = action {
content.append(" nostr:" + bech32_note_id(ev.id))

if let quoted_ev = state.events.lookup(ev.id) {
tags.append(["p", quoted_ev.pubkey.hex()])
}
}

return NostrPost(content: content, references: references, kind: .text, tags: img_meta_tags)
return NostrPost(content: content, references: references, kind: .text, tags: tags)
}

0 comments on commit 7710839

Please sign in to comment.