mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-22 20:44:56 +00:00
add padding and random order to DMs copy-to-self
This commit is contained in:
parent
4a0a21550b
commit
6a15c24f6a
@ -1821,11 +1821,6 @@ Value newdirectmsg(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
std::list<entry *> dmsToSend;
|
std::list<entry *> dmsToSend;
|
||||||
|
|
||||||
entry dmOldFormat;
|
|
||||||
if( !createDirectMessage(dmOldFormat, strTo, strMsg) )
|
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR,
|
|
||||||
"error encrypting to pubkey of destination user");
|
|
||||||
|
|
||||||
entry payloadNewFormat;
|
entry payloadNewFormat;
|
||||||
payloadNewFormat["msg"] = strMsg;
|
payloadNewFormat["msg"] = strMsg;
|
||||||
payloadNewFormat["to"] = strTo;
|
payloadNewFormat["to"] = strTo;
|
||||||
@ -1833,6 +1828,19 @@ Value newdirectmsg(const Array& params, bool fHelp)
|
|||||||
bencode(std::back_inserter(payloadbuf), payloadNewFormat);
|
bencode(std::back_inserter(payloadbuf), payloadNewFormat);
|
||||||
std::string strMsgData = std::string(payloadbuf.data(),payloadbuf.size());
|
std::string strMsgData = std::string(payloadbuf.data(),payloadbuf.size());
|
||||||
|
|
||||||
|
if( copySelf ) {
|
||||||
|
// add padding to strMsg so both DMs will have exactly the same size.
|
||||||
|
// should be removed in future when all clients move to new format.
|
||||||
|
while( strMsg.length() < strMsgData.length() ) {
|
||||||
|
strMsg.push_back(' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entry dmOldFormat;
|
||||||
|
if( !createDirectMessage(dmOldFormat, strTo, strMsg) )
|
||||||
|
throw JSONRPCError(RPC_INTERNAL_ERROR,
|
||||||
|
"error encrypting to pubkey of destination user");
|
||||||
|
|
||||||
entry dmNewFormat;
|
entry dmNewFormat;
|
||||||
if( copySelf ) {
|
if( copySelf ) {
|
||||||
// use new format to send a copy to ourselves. in future, message
|
// use new format to send a copy to ourselves. in future, message
|
||||||
@ -1840,9 +1848,14 @@ Value newdirectmsg(const Array& params, bool fHelp)
|
|||||||
if( !createDirectMessage(dmNewFormat, strFrom, strMsgData) )
|
if( !createDirectMessage(dmNewFormat, strFrom, strMsgData) )
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR,
|
throw JSONRPCError(RPC_INTERNAL_ERROR,
|
||||||
"error encrypting to pubkey of destination user");
|
"error encrypting to pubkey of destination user");
|
||||||
// TODO: random order
|
|
||||||
dmsToSend.push_back(&dmOldFormat);
|
if( rand() < (RAND_MAX/2) ) {
|
||||||
dmsToSend.push_back(&dmNewFormat);
|
dmsToSend.push_back(&dmOldFormat);
|
||||||
|
dmsToSend.push_back(&dmNewFormat);
|
||||||
|
} else {
|
||||||
|
dmsToSend.push_back(&dmNewFormat);
|
||||||
|
dmsToSend.push_back(&dmOldFormat);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dmsToSend.push_back(&dmOldFormat);
|
dmsToSend.push_back(&dmOldFormat);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user