MessageOrigin.fromJson constructor

MessageOrigin.fromJson(
  1. Map<String, dynamic> json
)

Creates a new MessageOrigin instance from a JSON object.

Implementation

factory MessageOrigin.fromJson(Map<String, dynamic> json) {
  return switch (MessageOriginType.from(json['type'])) {
    MessageOriginType.user => MessageOriginUser.fromJson(json),
    MessageOriginType.hiddenUser => MessageOriginHiddenUser.fromJson(json),
    MessageOriginType.chat => MessageOriginChat.fromJson(json),
    MessageOriginType.channel => MessageOriginChannel.fromJson(json),
  };
}