Skip to content

Commit

Permalink
Merge pull request #208 from RocketChat/new-room-type-changes
Browse files Browse the repository at this point in the history
[NEW] Add MessageType indicating change to private group and channel
  • Loading branch information
philipbrito authored Oct 5, 2018
2 parents 107d956 + e146e91 commit 9b38f52
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/src/main/kotlin/chat/rocket/core/model/Message.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ sealed class MessageType {
@Json(name = "subscription-role-removed")
class SubscriptionRoleRemoved : MessageType()

@Json(name = "room_changed_privacy")
class RoomChangedPrivacy : MessageType()

class Unspecified(val rawType: String) : MessageType()
}

Expand All @@ -110,6 +113,7 @@ fun MessageType?.asString(): String? {
is MessageType.UserUnMuted -> "user-unmuted"
is MessageType.SubscriptionRoleAdded -> "subscription-role-added"
is MessageType.SubscriptionRoleRemoved -> "subscription-role-removed"
is MessageType.RoomChangedPrivacy -> "room_changed_privacy"
else -> null
}
}
Expand All @@ -125,6 +129,7 @@ fun Message.isSystemMessage() = when (type) {
is MessageType.UserUnMuted,
is MessageType.SubscriptionRoleAdded,
is MessageType.SubscriptionRoleRemoved,
is MessageType.RoomChangedPrivacy,
is MessageType.MessagePinned -> true
else -> false
}
Expand All @@ -143,7 +148,8 @@ fun messageTypeOf(type: String?): MessageType? {
"user-unmuted" -> MessageType.UserUnMuted()
"subscription-role-added" -> MessageType.SubscriptionRoleAdded()
"subscription-role-removed" -> MessageType.SubscriptionRoleAdded()
"room_changed_privacy" -> MessageType.RoomChangedPrivacy()
null -> null
else -> MessageType.Unspecified(type)
}
}
}

0 comments on commit 9b38f52

Please sign in to comment.