钉钉web版防撤回、屏蔽已读
改造后,程序下载地址:
https://gitee.com/demos-proj/cef-sharp-demo63.0.3/attach_files/795697/download/DingDingWeb.7z
原理
1. 说明
网页钉钉地址
app.js文件
https://g.alicdn.com/DingTalkWeb/web/3.8.10/assets/app.js
钉钉关键代码
// 接收加密消息
_onMessage: function(e) {
try {
var t = JSON.parse(e.data)
} catch (t) {
return void this.localLog.error("WKSDK: ", this.name + " parse json error :" + e.data)
}
...
}
// 解密消息
i.prototype.dispatchMsg = function(e) {
var t = this
, n = e.map(function(e) {
return function() {
var e = this.dataItem.objectType
, n = null;
try {
// n 为解密后的消息对象
n = r.decodeFromB64(this.dataItem.data),
m[e] ? n = m[e](n) : d.error("can't decode sync data, object type: ", e)
} catch (e) {
return d.error("decode sync data error", n, e),
Promise.resolve()
}
}
}
...
}
// 发送消息
// e为类型,n为参数
// /r/IDLMessageStatus/updateToView
// /r/IDLMessageStatus/updateToRead
// /r/IDLSend/send
sendMsg: function(e, t, n, i) {
var o = new r(e,t,n,i);
if (this.state === a.OPENED || this.state === a.REGED || this.state === a.SUBSCRIBED) {
if ("/reg" === e)
return this._send(o.msgEntity) ? (this._addPending(o),
this.state === a.OPENED && (o.canSendBeforeAuth() ? (this.waitingRegMsgs.push(o),
} else
this.state === a.CLOSED || this.state === a.INITED ? (o.sendOfflineMsg()
return o
},
2. 消息类型
objectType | data |
---|---|
1000 | 文本、表情、图片、文件、视频、点赞、名片、收藏 |
1002 | 删除消息 |
1001 | 撤回消息 |
1003 | 附加消息-详细 |
1005 | 附加消息-简版 |
3. 改造
3.1 发送、接收消息拦截
在消息发送、接收处,输出日志
sendMsg: function(e, t, n, i) {
/******拦截发送消息******/
console.log("【发送消息】" + JSON.stringify(e) + "\r\n" + JSON.stringify(n));
//debugger;
/*********************/
var o = new r(e,t,n,i);
if (this.state === a.OPENED || this.state === a.REGED || this.state === a.SUBSCRIBED) {
}
}
i.prototype.dispatchMsg = function(e) {
var t = this
, n = e.map(function(e) {
return function() {
var e = this.dataItem.objectType
, n = null;
try {
n = r.decodeFromB64(this.dataItem.data),
m[e] ? n = m[e](n) : d.error("can't decode sync data, object type: ", e)
/******拦截接收消息******/
console.log("【接收消息】" + JSON.stringify(e) + "\r\n" + JSON.stringify(n));
//debugger;
/*********************/
debugger;
} catch (e) {
return d.error("decode sync data error", n, e),
Promise.resolve()
}
}
3.2 防撤回
在消息接收处,拦截撤回消息
i.prototype.dispatchMsg = function(e) {
var t = this
, n = e.map(function(e) {
return function() {
var e = this.dataItem.objectType
, n = null;
try {
n = r.decodeFromB64(this.dataItem.data),
m[e] ? n = m[e](n) : d.error("can't decode sync data, object type: ", e)
/******防撤回******/
if(e == 1001)
{
console.log("【防撤回】" + JSON.stringify(e) + "\r\n" + JSON.stringify(n));
return;
}
/*********************/
} catch (e) {
return d.error("decode sync data error", n, e),
Promise.resolve()
}
}
3.3 屏蔽已读
在消息发送处,拦截已读相关消息发送
sendMsg: function(e, t, n, i) {
/******屏蔽已读******/
if(e == "/r/IDLMessageStatus/updateToView" ||
e == "/r/IDLMessageStatus/updateToRead")
{
console.log("【屏蔽已读】" + JSON.stringify(e) + "\r\n" + JSON.stringify(n));
return;
}
/*********************/
var o = new r(e,t,n,i);
if (this.state === a.OPENED || this.state === a.REGED || this.state === a.SUBSCRIBED) {
}
}