Support for experimental MSC4286 to not render external payment details

Ref: https://github.com/matrix-org/matrix-spec-proposals/pull/4286
This commit is contained in:
Hugh Nimmo-Smith
2025-05-07 12:36:23 +01:00
parent 0bd4e016a9
commit f7fc8b807a
2 changed files with 28 additions and 0 deletions
@@ -23,6 +23,16 @@ public extension DTHTMLElement {
// Remove any attachments to fix rendering.
textAttachment = nil
// Handle special case for span with data-mx-external-payment-details
// This could be based on Storefront.current.countryCode to show the link
// content in unrestricted countries. e.g. currently USA
if name == "span",
let attributes = attributes as? [String: String],
attributes["data-msc4286-external-payment-details"] != nil {
parent.removeChildNode(self)
return
}
// If the element has plain text content show that,
// otherwise prevent the tag from displaying.
if let stringContent = attributedString()?.string,