diff --git a/apps/ios/Shared/Views/Chat/ChatItem/MsgContentView.swift b/apps/ios/Shared/Views/Chat/ChatItem/MsgContentView.swift index 3212f3f512..30ed3fa1a4 100644 --- a/apps/ios/Shared/Views/Chat/ChatItem/MsgContentView.swift +++ b/apps/ios/Shared/Views/Chat/ChatItem/MsgContentView.swift @@ -373,6 +373,7 @@ func messageText( attrs[linkAttrKey] = NSURL(string: "tel:" + t.replacingOccurrences(of: " ", with: "")) handleTaps = true } + case .unknown: () case .none: () } res.append(NSAttributedString(string: t, attributes: attrs)) diff --git a/apps/ios/SimpleXChat/ChatTypes.swift b/apps/ios/SimpleXChat/ChatTypes.swift index faf7963192..db370efdc1 100644 --- a/apps/ios/SimpleXChat/ChatTypes.swift +++ b/apps/ios/SimpleXChat/ChatTypes.swift @@ -4449,6 +4449,7 @@ public enum Format: Decodable, Equatable, Hashable { case mention(memberName: String) case email case phone + case unknown public var isSimplexLink: Bool { get { diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt index 365f85cfbc..d61e44f528 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt @@ -4352,6 +4352,7 @@ sealed class Format { @Serializable @SerialName("mention") class Mention(val memberName: String): Format() @Serializable @SerialName("email") class Email: Format() @Serializable @SerialName("phone") class Phone: Format() + @Serializable @SerialName("unknown") class Unknown: Format() val style: SpanStyle @Composable get() = when (this) { is Bold -> SpanStyle(fontWeight = FontWeight.Bold) @@ -4365,6 +4366,7 @@ sealed class Format { is Mention -> SpanStyle(fontWeight = FontWeight.Medium) is Email -> linkStyle is Phone -> linkStyle + is Unknown -> SpanStyle() } val isSimplexLink = this is SimplexLink diff --git a/bots/src/API/Docs/Types.hs b/bots/src/API/Docs/Types.hs index de1c664c24..fd8529ff52 100644 --- a/bots/src/API/Docs/Types.hs +++ b/bots/src/API/Docs/Types.hs @@ -255,7 +255,7 @@ chatTypesDocsData = (sti @FileProtocol, (STEnum' $ consLower "FP"), "", [], "", ""), (sti @FileStatus, STEnum, "FS", [], "", ""), (sti @FileTransferMeta, STRecord, "", [], "", ""), - (sti @Format, STUnion, "", [], "", ""), + (sti @Format, STUnion, "", ["Unknown"], "", ""), (sti @FormattedText, STRecord, "", [], "", ""), (sti @FullGroupPreferences, STRecord, "", [], "", ""), (sti @FullPreferences, STRecord, "", [], "", ""), diff --git a/bots/src/API/TypeInfo.hs b/bots/src/API/TypeInfo.hs index 90f9cdb186..d8efd21742 100644 --- a/bots/src/API/TypeInfo.hs +++ b/bots/src/API/TypeInfo.hs @@ -170,6 +170,7 @@ toTypeInfo tr = "FormatColor" -> ST "Color" [] "CustomData" -> ST "JSONObject" [] "KeyMap" -> ST "JSONObject" [] + "Value" -> ST "JSONObject" [] "CIQDirection" -> ST "CIDirection" [] "SendRef" -> ST "ChatRef" [] t diff --git a/src/Simplex/Chat/Markdown.hs b/src/Simplex/Chat/Markdown.hs index 79365c8243..f368631852 100644 --- a/src/Simplex/Chat/Markdown.hs +++ b/src/Simplex/Chat/Markdown.hs @@ -53,6 +53,7 @@ data Format | Mention {memberName :: Text} | Email | Phone + | Unknown {json :: J.Value} deriving (Eq, Show) mentionedNames :: MarkdownList -> [Text] @@ -305,6 +306,7 @@ markdownText (FormattedText f_ t) = case f_ of Mention _ -> t Email -> t Phone -> t + Unknown _ -> t where around c = c `T.cons` t `T.snoc` c color c = case colorStr c of @@ -340,7 +342,10 @@ viewName s = if T.any isSpace s || maybe False (isPunctuation . snd) (T.unsnoc s $(JQ.deriveJSON (enumJSON $ dropPrefix "XL") ''SimplexLinkType) -$(JQ.deriveJSON (sumTypeJSON fstToLower) ''Format) +$(JQ.deriveToJSON (sumTypeJSON fstToLower) ''Format) + +instance FromJSON Format where + parseJSON v = $(JQ.mkParseJSON (sumTypeJSON fstToLower) ''Format) v <|> pure (Unknown v) $(JQ.deriveJSON defaultJSON ''FormattedText)