Rich message rendering #24
5 changed files with 12 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
|||
const {Event} = require("./event")
|
||||
const {MatrixEvent} = require("./event")
|
||||
|
||||
class EncryptedMessage extends Event {
|
||||
class EncryptedMessage extends MatrixEvent {
|
||||
render() {
|
||||
super.render()
|
||||
return this.text("Carbon cannot render encrypted messages yet")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {ElemJS, ejs} = require("../basic")
|
||||
const {dateFormatter} = require("../dateFormatter")
|
||||
|
||||
class Event extends ElemJS {
|
||||
class MatrixEvent extends ElemJS {
|
||||
constructor(data) {
|
||||
super("div")
|
||||
this.class("c-message")
|
||||
|
@ -52,8 +52,4 @@ class Event extends ElemJS {
|
|||
|
||||
|
||||
|
||||
function renderEvent(event) {
|
||||
return new events.find(e => e.canRender(event))(event)
|
||||
}
|
||||
|
||||
module.exports = {renderEvent, Event}
|
||||
module.exports = {MatrixEvent}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {Event} = require("./event")
|
||||
const {MatrixEvent} = require("./event")
|
||||
|
||||
function createMembershipEvent(membership, message) {
|
||||
return class extends Event {
|
||||
return class extends MatrixEvent {
|
||||
render() {
|
||||
super.render()
|
||||
return this.text(message(this.data))
|
||||
|
@ -13,7 +13,7 @@ function createMembershipEvent(membership, message) {
|
|||
|
||||
}
|
||||
}
|
||||
class UnknownMembership extends Event {
|
||||
class UnknownMembership extends MatrixEvent {
|
||||
render() {
|
||||
super.render()
|
||||
return this.text("Unsupported membership event")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {ejs} = require("../basic")
|
||||
const DOMPurify = require("dompurify")
|
||||
const {resolveMxc} = require("../functions")
|
||||
const {Event} = require("./event")
|
||||
const {MatrixEvent} = require("./event")
|
||||
|
||||
const purifier = DOMPurify()
|
||||
|
||||
|
@ -67,7 +67,7 @@ function sanitize(html) {
|
|||
return purifier.sanitize(html)
|
||||
}
|
||||
|
||||
class HTMLMessage extends Event {
|
||||
class HTMLMessage extends MatrixEvent {
|
||||
render() {
|
||||
super.render()
|
||||
let html = this.data.content.formatted_body
|
||||
|
@ -89,7 +89,7 @@ class HTMLMessage extends Event {
|
|||
|
||||
}
|
||||
|
||||
class TextMessage extends Event {
|
||||
class TextMessage extends MatrixEvent {
|
||||
render() {
|
||||
super.render()
|
||||
return this.text(this.data.content.body)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const {Event} = require("./event")
|
||||
const {MatrixEvent} = require("./event")
|
||||
|
||||
class UnknownEvent extends Event {
|
||||
class UnknownEvent extends MatrixEvent {
|
||||
render() {
|
||||
super.render()
|
||||
this.text("Cannot render event")
|
||||
|
|
Loading…
Reference in a new issue