-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should drastically increase compatibility for damus replies in other clients. Also filter non-pubkey references when replying so we don't run into the q-tag bug. Changelog-Added: Added nip10 marker replies Changelog-Fixed: Fixed issue where some replies were including the q tag Fixes: #2239 Fixes: #2233 Signed-off-by: William Casarin <[email protected]>
- Loading branch information
Showing
10 changed files
with
231 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// ThreadReply.swift | ||
// damus | ||
// | ||
// Created by William Casarin on 2024-05-09. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
struct ThreadReply { | ||
let root: NoteRef | ||
let reply: NoteRef? | ||
let mention: Mention<NoteRef>? | ||
|
||
var is_reply_to_root: Bool { | ||
guard let reply else { | ||
// if we have no reply and only root then this is reply-to-root, | ||
// but it should never really be in this form... | ||
return true | ||
} | ||
|
||
return root.id == reply.id | ||
} | ||
|
||
init(root: NoteRef, reply: NoteRef?, mention: Mention<NoteRef>?) { | ||
self.root = root | ||
self.reply = reply | ||
self.mention = mention | ||
} | ||
|
||
init?(event_refs: [EventRef]) { | ||
var root: NoteRef? = nil | ||
var reply: NoteRef? = nil | ||
var mention: Mention<NoteRef>? = nil | ||
|
||
for evref in event_refs { | ||
switch evref { | ||
case .mention(let m): | ||
mention = m | ||
case .thread_id(let r): | ||
root = r | ||
case .reply(let r): | ||
reply = r | ||
case .reply_to_root(let r): | ||
root = r | ||
reply = r | ||
} | ||
} | ||
|
||
// nip10 threads must have a root | ||
guard let root else { | ||
return nil | ||
} | ||
|
||
self = ThreadReply(root: root, reply: reply, mention: mention) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.