diff --git a/Telegram/NotificationService/Sources/NotificationService.swift b/Telegram/NotificationService/Sources/NotificationService.swift index de697ef595..bde66723dd 100644 --- a/Telegram/NotificationService/Sources/NotificationService.swift +++ b/Telegram/NotificationService/Sources/NotificationService.swift @@ -1978,13 +1978,18 @@ private final class NotificationServiceHandler { if let media = message.media.first { parsedMedia = media } - if enableInlineEmoji, let textEntitiesAttribute = message.textEntitiesAttribute { - content.body = message.text + if enableInlineEmoji, let textEntitiesAttribute = message.textEntitiesAttribute, let author = message.author { + let authorTitle = author.debugDisplayTitle + let messagePrefix = "\(authorTitle): " + let messagePrefixLength = (messagePrefix as NSString).length for entity in textEntitiesAttribute.entities { if case let .CustomEmoji(_, fileId) = entity.type { - content.customEmoji.append(NotificationContent.CustomEmoji(range: entity.range, fileId: fileId)) + content.customEmoji.append(NotificationContent.CustomEmoji(range: (entity.range.lowerBound + messagePrefixLength) ..< (entity.range.upperBound + messagePrefixLength), fileId: fileId)) } } + if !content.customEmoji.isEmpty { + content.body = messagePrefix + message.text + } } } diff --git a/submodules/TelegramApi/Sources/Buffer.swift b/submodules/TelegramApi/Sources/Buffer.swift index 4a58e1f7bf..8ec5a23b82 100644 --- a/submodules/TelegramApi/Sources/Buffer.swift +++ b/submodules/TelegramApi/Sources/Buffer.swift @@ -363,13 +363,16 @@ public class BufferReader { if count == 0 { return 0 } - else if count > 0 && count <= 4 || self.offset + UInt(count) <= self.buffer._size { - var value: Int32 = 0 - memcpy(&value, self.buffer.data?.advanced(by: Int(self.offset)), count) - self.offset += UInt(count) - return value + guard count > 0, count <= 4, self.offset + UInt(count) <= self.buffer._size else { + return nil } - return nil + guard let bufferData = self.buffer.data else { + return nil + } + var value: Int32 = 0 + memcpy(&value, bufferData.advanced(by: Int(self.offset)), count) + self.offset += UInt(count) + return value } public func readBuffer(_ count: Int) -> Buffer? {