Add unknown memberships
This commit is contained in:
parent
098ea88f5d
commit
1a8427925c
1 changed files with 14 additions and 3 deletions
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue