uni-im-msg.schema.json 3.6 KB
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
{
  "bsonType": "object",
  "description": "im消息表",
  "permission": {
    "create": false,
    "delete": false,
    "read": true, // 在触发器中限制
    "update": false
  },
  "required": [
    "to_uid",
    "body",
    "type"
  ],
  "properties": {
    "_id": {
      "description": "ID,系统自动生成"
    },
    "from_uid": {
      "bsonType": "string",
      "description": "消息发送方 UserID(用于指定发送消息方帐号)",
      "forceDefaultValue": {
        "$env": "uid"
      }
    },
DCloud_JSON's avatar
3.4.31  
DCloud_JSON 已提交
26 27 28 29 30 31 32 33
    "nickname": {
    	"bsonType": "string",
    	"description": "冗余的消息发送者昵称"
    },
    "avatar_file": {
    	"bsonType": "file",
    	"title": "冗余的消息发送者头像文件"
    },
DCloud_JSON's avatar
DCloud_JSON 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
    "to_uid": {
      "bsonType": "string",
      "description": "消息接收方 UserID"
    },
    "conversation_id": {
      "bsonType": "string",
      "description": "conversation_id即消息的会话id",
      "foreignKey": "uni-im-conversation.id"
    },
    "group_id": {
      "bsonType": "string",
      "description": "group_id即消息接收群的id"
    },
    "body": {
      "description": "消息内容,包含的键会随type变化。需要自己写valedateFunction验证"
    },
    "reader_list": {
      "bsonType": "array",
      "description": "已读用户列表",
      "forceDefaultValue": []
    },
    "is_read": {
      "bsonType": "bool",
      "description": "是否已读(单聊时使用)",
      "forceDefaultValue": false
    },
    "type": {
      "bsonType": "string",
      "enum": [{
          "text": "文本",
          "value": "text"
        },
        {
          "text": "图像",
          "value": "image"
        },
        {
          "text": "语音",
          "value": "sound"
        },
        {
          "text": "视频",
          "value": "video"
        },
        {
          "text": "文件",
          "value": "file"
        },
        {
          "text": "代码",
          "value": "code"
        },
        {
          "text": "历史消息(来源用户转发)",
          "value": "history"
        },
        {
          "text": "富文本",
          "value": "rich-text"
        },
        {
          "text": "位置",
          "value": "location"
        },
        {
          "text": "系统消息",
          "value": "system"
        },
        {
          "text": "名片",
          "value": "userinfo-card"
        }
      ]
    },
    "__text": {
      "bsonType": "string",
      "description": "私有冗余字段,方便实现:历史消息搜索功能"
    },
    "state": {
      "bsonType": "int",
      "description": "0 发送中,100发送成功,-100 发送失败,-200 禁止发送(内容不合法)"
    },
    "is_revoke": {
      "bsonType": "bool",
      "description": "是否被撤回",
      "defaultValue": false
    },
    "about_msg_id": {
      "bsonType": "string",
      "description": "关于某条消息的id,一般用于回复某一条消息",
      "defaultValue": false
    },
    "appid": {
      "bsonType": "string",
      "description": "接收消息的appid"
    },
    "create_time": {
      "bsonType": "timestamp",
      "description": "消息发送时间戳",
      "forceDefaultValue": {
        "$env": "now"
      }
    },
    "update_time": {
      "bsonType": "timestamp",
      "description": "消息更新时间戳",
      "forceDefaultValue": {
        "$env": "now"
      }
    },
    "client_create_time": {
      "bsonType": "timestamp",
      "description": "客户端创建消息的时间戳",
      "forceDefaultValue": {
        "$env": "now"
      }
    }
  }
}