From 7c82ede432223ab603c1b766a8ca2281fa98e664 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Tue, 3 Aug 2021 14:25:10 +1000 Subject: [PATCH] fix a minor mention issue that it won't show the name if there is no white space after a mention --- Session/Utilities/MentionUtilities.swift | 2 +- .../NotificationServiceExtension.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Session/Utilities/MentionUtilities.swift b/Session/Utilities/MentionUtilities.swift index 5c888b09d..0faeb712a 100644 --- a/Session/Utilities/MentionUtilities.swift +++ b/Session/Utilities/MentionUtilities.swift @@ -14,7 +14,7 @@ public final class MentionUtilities : NSObject { MentionsManager.populateUserPublicKeyCacheIfNeeded(for: threadID, in: transaction) } var string = string - let regex = try! NSRegularExpression(pattern: "@[0-9a-fA-F]*", options: []) + let regex = try! NSRegularExpression(pattern: "@[0-9a-fA-F]{66}", options: []) let knownPublicKeys = MentionsManager.userPublicKeyCache[threadID] ?? [] // Should always be populated at this point var mentions: [(range: NSRange, publicKey: String)] = [] var outerMatch = regex.firstMatch(in: string, options: .withoutAnchoringBounds, range: NSRange(location: 0, length: string.utf16.count)) diff --git a/SessionNotificationServiceExtension/NotificationServiceExtension.swift b/SessionNotificationServiceExtension/NotificationServiceExtension.swift index fd51ffd0b..9565a7be4 100644 --- a/SessionNotificationServiceExtension/NotificationServiceExtension.swift +++ b/SessionNotificationServiceExtension/NotificationServiceExtension.swift @@ -201,7 +201,7 @@ private extension String { func replacingMentions(for threadID: String, using transaction: YapDatabaseReadWriteTransaction) -> String { MentionsManager.populateUserPublicKeyCacheIfNeeded(for: threadID, in: transaction) var result = self - let regex = try! NSRegularExpression(pattern: "@[0-9a-fA-F]*", options: []) + let regex = try! NSRegularExpression(pattern: "@[0-9a-fA-F]{66}", options: []) let knownPublicKeys = MentionsManager.userPublicKeyCache[threadID] ?? [] var mentions: [(range: NSRange, publicKey: String)] = [] var m0 = regex.firstMatch(in: result, options: .withoutAnchoringBounds, range: NSRange(location: 0, length: result.utf16.count))