fromProto static method

MsgModel fromProto(
  1. MsgData msgData,
  2. AesParams? aesParams
)

Implementation

static MsgModel fromProto(MsgData msgData, AesParams? aesParams) {
  MsgOptionsModel options = MsgOptionsModel.fromProto(msgData.options);
  return MsgModel(
    clientMsgId: msgData.clientMsgId,
    serverMsgId: msgData.serverMsgId,
    clientTime: int.parse(msgData.clientTime),
    serverTime: int.parse(msgData.serverTime),
    senderId: msgData.senderId,
    senderInfo: SDKTool.utf8Decode(msgData.senderInfo),
    convId: msgData.convId,
    atUsers: msgData.atUsers,
    contentType: msgData.contentType,
    content: options.needDecrypt == true && aesParams != null
        ? SDKTool.aesDecode(
            key: aesParams.key,
            iv: aesParams.iv,
            bytes: msgData.content,
          )
        : SDKTool.utf8Decode(msgData.content),
    seq: int.parse(msgData.seq),
    options: options,
    offlinePush: MsgOfflinePushModel.fromProto(msgData.offlinePush),
    ext: SDKTool.utf8Decode(msgData.ext),
  );
}