123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- package com.sikey.commonservice.model.database
- import com.google.gson.annotations.SerializedName
- import com.sikey.commonservice.model.http.xplora.chat.MsgListInfo
- import com.sikey.commonservice.modules.WatchStateChangeImpl
- /**
- * Chat Message Type Attributes
- * Voice msgId, type, fileUrl, dur, state, create, update
- * Text msgId, type, text, state, create, update
- * Emoji msgId, type, emojiId, state, create, update
- * Photo msgId, type, fileUrl, state, create, update
- * Short video msgId, type, dur, coverUrl, videoUrl, state, create, update
- * Mp3 msgId, type, fileUrl, dur, state, create, update
- */
- data class ChatDbDbEntity(
- @SerializedName("_id")
- var _id: Long? = null,
- @SerializedName("msgId")
- var msgId: String? = null,
- /**
- * - 100 : Emoji
- * - 101 : Text
- * - 102 : Photo
- * - 103 : Voice
- * - 104 : Mp3
- * - 105 : Short video
- */
- @SerializedName("type")
- var type: String? = null,
- @SerializedName("text")
- var text: String? = null,
- @SerializedName("emojiId")
- var emojiId: String? = null,
- /**
- * -image
- * -audio
- * -cover
- */
- @SerializedName("fileUrl")
- var fileUrl: String? = null,
- /**
- * file name of music file, empty string if no name or not a music
- */
- @SerializedName("fileName")
- var fileName: String? = null,
- /**
- * -image
- * -audio
- * -cover
- *
- * MESSAGE_STATE_UNDOWNLOAD = 0;
- * MESSAGE_STATE_DOWNLOAD_ING = 1;
- * MESSAGE_STATE_NEED_DOWNLOAD = 2
- * MESSAGE_STATE_DOWNLOAD_DONE = uri;
- */
- @SerializedName("filePath")
- var filePath: String? = null,
- /**
- * -audio
- * -video
- */
- @SerializedName("dur")
- var dur: String? = null,
- /**
- * -video
- */
- @SerializedName("videoUrl")
- var videoUrl: String? = null,
- /**
- * MESSAGE_STATE_UNDOWNLOAD = 0;
- * MESSAGE_STATE_DOWNLOAD_ING = 1;
- * MESSAGE_STATE_NEED_DOWNLOAD = 2
- * MESSAGE_STATE_DOWNLOAD_DONE = uri;
- */
- @SerializedName("videoPath")
- var videoPath: String? = null,
- /**
- * Message status
- * - 0 : Unknown
- * - 1 : Delivered
- * - 2 : Read
- * - 3 : Failed
- */
- @SerializedName("state")
- var state: String? = null,
- /**
- * MESSAGE_STATE_UNREAD = 0;
- * MESSAGE_STATE_READ = 1;
- * MESSAGE_STATE_SEND_ING = 2;
- * MESSAGE_STATE_SEND_SUCCESS = 3;e
- * MESSAGE_STATE_SEND_FAIL = 4;
- * MESSAGE_STATE_DELETE = 5;
- * MESSAGE_STATE_UNKNOWN = 99;
- */
- @SerializedName("localState")
- var localState: String = "0",
- @SerializedName("senderUserId")
- var senderUserId: String? = null,
- @SerializedName("receiverId")
- var receiverId: String? = null,
- @SerializedName("create")
- var create: String? = null,
- @SerializedName("update")
- var update: String? = null,
- @SerializedName("fid")
- var fid: String? = null
- ) : BaseDbEntity() {
- fun from(info: com.sikey.commonservice.model.http.xplora.chat.BaseMsgInfo<*>): ChatDbDbEntity {
- msgId = info.msgId
- type = info.type
- text = info.text
- emojiId = info.emojiId
- fileUrl = if (info.type == "105") info.coverUrl else info.fileUrl
- dur = info.dur
- videoUrl = info.videoUrl
- state = info.state
- create = info.create
- update = info.update
- when (info) {
- is com.sikey.commonservice.model.http.xplora.chat.MsgInfo -> {
- senderUserId = info.senderUserId
- receiverId = WatchStateChangeImpl.watchBaseInfo.userId
- }
- is MsgListInfo -> {
- if (!info.incomming) {
- senderUserId = WatchStateChangeImpl.watchBaseInfo.userId
- }
- }
- }
- return this
- }
- }
|