commit 812abba8d46647c8d4e65a5b9837c53b5447837b
parent 300463ef5516e93f54b0bf1f8b1bee18694c8727
Author: William Casarin <jb55@jb55.com>
Date: Sun, 8 May 2022 19:31:40 -0700
fix incredible bug lol
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/damus/Models/Mentions.swift b/damus/Models/Mentions.swift
@@ -137,7 +137,7 @@ func find_tag_ref(type: String, id: String, tags: [[String]]) -> Int? {
return i
}
}
- i += i
+ i += 1
}
return nil
diff --git a/damusTests/ReplyTests.swift b/damusTests/ReplyTests.swift
@@ -132,6 +132,23 @@ class ReplyTests: XCTestCase {
XCTAssertEqual(post_tags.tags[0][1], pk)
}
+ func testReplyMentions() throws {
+ let privkey = "0fc2092231f958f8d57d66f5e238bb45b6a2571f44c0ce024bbc6f3a9c8a15fe"
+ let pubkey = "30c6d1dc7f7c156794fa15055e651b758a61b99f50fcf759de59386050bf6ae2"
+
+ let refs = [
+ ReferencedId(ref_id: "thread_id", relay_id: nil, key: "e"),
+ ReferencedId(ref_id: "reply_id", relay_id: nil, key: "e"),
+ ReferencedId(ref_id: pubkey, relay_id: nil, key: "p"),
+ ]
+
+ let post = NostrPost(content: "this is a (@\(pubkey)) mention", references: refs)
+ let ev = post_to_event(post: post, privkey: privkey, pubkey: pubkey)
+
+ XCTAssertEqual(ev.content, "this is a (#[2]) mention")
+ XCTAssertEqual(ev.tags[2][1], pubkey)
+ }
+
func testInvalidPostReference() throws {
let pk = "32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e24"
let content = "this is a @\(pk) mention"