Add unknown memberships

This commit is contained in:
Bad 2020-10-26 22:55:27 +01:00
parent 098ea88f5d
commit 1a8427925c

View file

@ -1,10 +1,10 @@
const {Event} = require("./event")
function createMembershipEvent(membership, text) {
function createMembershipEvent(membership, message) {
return class extends Event {
render() {
super.render()
return this.text(text(this.data))
return this.text(message(this.data))
}
static canRender(event) {
@ -13,9 +13,20 @@ function createMembershipEvent(membership, text) {
}
}
class UnknownMembership extends Event {
render() {
super.render()
return this.text("Unsupported membership event")
}
static canRender(event) {
return event.type == "m.room.member"
}
}
const JoinedEvent = createMembershipEvent("join", () => "joined the room")
const InvitedEvent = createMembershipEvent("invite", (e) => `invited ${e.content.displayname} the room`)
const LeaveEvent = createMembershipEvent("leave", () => "left the room")
module.exports = [JoinedEvent, InvitedEvent, LeaveEvent]
module.exports = [JoinedEvent, InvitedEvent, LeaveEvent, UnknownMembership]