Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search message history #23

Open
hawkwithwind opened this issue Apr 30, 2019 · 5 comments
Open

search message history #23

hawkwithwind opened this issue Apr 30, 2019 · 5 comments

Comments

@hawkwithwind
Copy link
Owner

hawkwithwind commented Apr 30, 2019

path

/message/history

支持 GET, POST

GET /message/history?q=queryjson
POST /message/history
application/json 
{ 
   ... query json ...
}

queryjson

{
     "find": {
                "fromUser": {  "in": [ "wxid_...", ... ],    "equals": "wxid_..."},
                "toUser":     {  "in": [ "wxid_...", ... ],    "equals": "wxid_..."},
                "groupId":   {  "in": [ "wxid_...", ... ],    "equals": "wxid_..."}, 
                "sendAt":  { "gt": "2019-04-01T00:00:00Z", "lt": "2019-04-01T23:59:59Z"}
      },
     "sort": {
              "sendAt" : "desc",  
      },
     "paging": {
               "page":  1,
               "pagesize":  10,  // 特殊定义:这个pagesize指的是每个chatuser 或每个group 的 pagesize,不是整体的
      }
}

权限控制

根据当前访问者的cookie中对应的account, 查询相关botId,查询涉及到联系人中是否覆盖chatusers和chatgroups。过滤权限不足的,仅返回有权限的。

response

{
"code": 0,
"message": "成功", // 若部分权限不足,返回message “部分请求权限不足”
"body": [
    {
          "groupId": "...@chatroom",
          "messages": [
               { ... }, ... 
          ] ,
    }, {
          "toUser": "wxid_...",
          "messages": [
               { ... }, ...
          ]
   }, ...
],
"paging": {"pagesize": 10, "page": 1}
}
@vagase
Copy link
Collaborator

vagase commented Apr 30, 2019

建议分页参数采用 message id + limit 的模式,在聊天室消息增加的情况下 page + pagesize 可能会不准确

@hawkwithwind
Copy link
Owner Author

msgid 我不知道是否保证顺序,简化问题起见,建议用发送时间来比较

 "sendAt":  { "gt": "2019-04-01T00:00:00Z", "lt": "2019-04-01T23:59:59Z"}

@hawkwithwind
Copy link
Owner Author

hawkwithwind commented May 1, 2019

query

/chatusers/messages?q={%22find%22:{%22fromUser%22:%20{%22in%22:%20[%22wxid_b7rvs8pdawnu21%22,%20%22wxid_khb82ectt4dl22%22,%22wxid_ffk05mmvo73s22%22,%20%22vagase%22,%20%22wxid_exav0dswbva922%22]}}}

result

{
code: 0,
message: "some fromUser(s) are filtered by access control",
ts: 1556711042,
error: { },
body: {
wxid_b7rvs8pdawnu21: [
{
_id: "5cc97f7fb6d06d457426f284",
content: "good",
continue: 1,
description: "潘小强 : good",
fromUser: "wxid_b7rvs8pdawnu21",
groupId: "",
imageId: "",
mType: 1,
msgId: "9163343276054021840",
msgSource: {
atUserList: "",
memberCount: 0,
silence: 0
},
msgType: 5,
status: 1,
subType: 1,
timestamp: 1556709246,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
updatedAt: "2019-05-01T11:14:07.116Z"
},
{
_id: "5cc97f7ab6d06d457426f1f9",
content: "哈喽",
continue: 1,
description: "潘小强 : 哈喽",
fromUser: "wxid_b7rvs8pdawnu21",
groupId: "",
imageId: "",
mType: 1,
msgId: "2353871277956513537",
msgSource: {
atUserList: "",
memberCount: 0,
silence: 0
},
msgType: 5,
status: 1,
subType: 1,
timestamp: 1556709242,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
updatedAt: "2019-05-01T11:14:02.829Z"
}
]
},
paging: { }
}

@hawkwithwind
Copy link
Owner Author

hawkwithwind commented May 1, 2019

query

/chatgroups/8eeb6016-ed75-499f-ad82-ed4d358c6bb6/messages?q={%22paging%22:{%22pagesize%22:10}}

response

{
code: 0,
ts: 1556721531,
error: { },
body: [
{
msgId: "6767679681524538585",
msgType: 5,
imageId: "",
content: "恩恩",
groupId: "8815113045@chatroom",
description: "人在江湖漂 : 恩恩",
fromUser: "wxid_ffk05mmvo73s22",
mType: 1,
subType: 1,
status: 1,
continue: 1,
timestamp: 1556721518,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
msgSource: {
atUserList: "",
memberCount: 5,
silence: 0
},
updateAt: "2019-05-01T14:38:39.318Z"
},
{
msgId: "8350810476464791550",
msgType: 5,
imageId: "",
content: "然后再读这个,按照我给你那个key,再一个一个插上去,异步的。",
groupId: "8815113045@chatroom",
description: "潘小强 : 然后再读这个,按照我给你那个key,再一个一个插上去,异步的。",
fromUser: "wxid_b7rvs8pdawnu21",
mType: 1,
subType: 1,
status: 1,
continue: 1,
timestamp: 1556721505,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
msgSource: {
atUserList: "",
memberCount: 5,
silence: 0
},
updateAt: "2019-05-01T14:38:26.439Z"
},
{
msgId: "9127287641940780665",
msgType: 5,
imageId: "",
content: "群聊的消息我想了下可能有点麻烦",
groupId: "8815113045@chatroom",
description: "人在江湖漂 : 群聊的消息我想了下可能有点麻烦",
fromUser: "wxid_ffk05mmvo73s22",
mType: 1,
subType: 1,
status: 1,
continue: 1,
timestamp: 1556721482,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
msgSource: {
atUserList: "",
memberCount: 5,
silence: 0
},
updateAt: "2019-05-01T14:38:03.533Z"
},
{
msgId: "5759552994794729547",
msgType: 5,
imageId: "",
content: "我建议是你先把用户信息显示到界面上",
groupId: "8815113045@chatroom",
description: "潘小强 : 我建议是你先把用户信息显示到界面上",
fromUser: "wxid_b7rvs8pdawnu21",
mType: 1,
subType: 1,
status: 1,
continue: 1,
timestamp: 1556721480,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
msgSource: {
atUserList: "",
memberCount: 5,
silence: 0
},
updateAt: "2019-05-01T14:38:00.933Z"
},
{
msgId: "7761860306965784455",
msgType: 5,
imageId: "",
content: "单聊没啥大问题",
groupId: "8815113045@chatroom",
description: "人在江湖漂 : 单聊没啥大问题",
fromUser: "wxid_ffk05mmvo73s22",
mType: 1,
subType: 1,
status: 1,
continue: 1,
timestamp: 1556721476,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
msgSource: {
atUserList: "",
memberCount: 5,
silence: 0
},
updateAt: "2019-05-01T14:37:57.097Z"
},
{
msgId: "6215958909477764580",
msgType: 5,
imageId: "",
content: "因为还得合并一次 把用户信息合并上去",
groupId: "8815113045@chatroom",
description: "人在江湖漂 : 因为还得合并一次 把用户信息合并上去",
fromUser: "wxid_ffk05mmvo73s22",
mType: 1,
subType: 1,
status: 1,
continue: 1,
timestamp: 1556721463,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
msgSource: {
atUserList: "",
memberCount: 5,
silence: 0
},
updateAt: "2019-05-01T14:37:44.423Z"
},
{
msgId: "6171945915797182573",
msgType: 5,
imageId: "",
content: "这玩意用的时候有点小麻烦",
groupId: "8815113045@chatroom",
description: "人在江湖漂 : 这玩意用的时候有点小麻烦",
fromUser: "wxid_ffk05mmvo73s22",
mType: 1,
subType: 1,
status: 1,
continue: 1,
timestamp: 1556721450,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
msgSource: {
atUserList: "",
memberCount: 5,
silence: 0
},
updateAt: "2019-05-01T14:37:30.973Z"
},
{
msgId: "136627389599880731",
msgType: 5,
imageId: "",
content: "我想清楚",
groupId: "8815113045@chatroom",
description: "人在江湖漂 : 我想清楚",
fromUser: "wxid_ffk05mmvo73s22",
mType: 1,
subType: 1,
status: 1,
continue: 1,
timestamp: 1556721439,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
msgSource: {
atUserList: "",
memberCount: 5,
silence: 0
},
updateAt: "2019-05-01T14:37:20.518Z"
},
{
msgId: "3342623386186550518",
msgType: 5,
imageId: "",
content: "恩恩",
groupId: "8815113045@chatroom",
description: "人在江湖漂 : 恩恩",
fromUser: "wxid_ffk05mmvo73s22",
mType: 1,
subType: 1,
status: 1,
continue: 1,
timestamp: 1556721437,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
msgSource: {
atUserList: "",
memberCount: 5,
silence: 0
},
updateAt: "2019-05-01T14:37:18.121Z"
},
{
msgId: "6666136456256332096",
msgType: 5,
imageId: "",
content: "好的,我得去跑步了",
groupId: "8815113045@chatroom",
description: "潘小强 : 好的,我得去跑步了",
fromUser: "wxid_b7rvs8pdawnu21",
mType: 1,
subType: 1,
status: 1,
continue: 1,
timestamp: 1556721432,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
msgSource: {
atUserList: "",
memberCount: 5,
silence: 0
},
updateAt: "2019-05-01T14:37:13.28Z"
}
],
paging: { }
}

@hawkwithwind
Copy link
Owner Author

hawkwithwind commented May 1, 2019

query

/chatusers/aad32ed0-18e7-4fa5-8932-8790e0f80d34/messages?q={%22find%22:{%22toUser%22:%22wxid_d9usx32sb9wy22%22}}

response

{
code: 0,
ts: 1556720925,
error: { },
body: [
{
msgId: "9163343276054021840",
msgType: 5,
imageId: "",
content: "good",
groupId: "",
description: "潘小强 : good",
fromUser: "wxid_b7rvs8pdawnu21",
mType: 1,
subType: 1,
status: 1,
continue: 1,
timestamp: 1556709246,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
msgSource: {
atUserList: "",
memberCount: 0,
silence: 0
},
updateAt: "2019-05-01T11:14:07.116Z"
},
{
msgId: "2353871277956513537",
msgType: 5,
imageId: "",
content: "哈喽",
groupId: "",
description: "潘小强 : 哈喽",
fromUser: "wxid_b7rvs8pdawnu21",
mType: 1,
subType: 1,
status: 1,
continue: 1,
timestamp: 1556709242,
toUser: "wxid_d9usx32sb9wy22",
uin: 3693868402,
msgSource: {
atUserList: "",
memberCount: 0,
silence: 0
},
updateAt: "2019-05-01T11:14:02.829Z"
}
],
paging: { }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants