You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
809 B
JavaScript
25 lines
809 B
JavaScript
5 years ago
|
var HK = module.exports;
|
||
|
|
||
|
/* getHash
|
||
|
* this function slices off the leading portion of a message which is
|
||
|
most likely unique
|
||
|
* these "hashes" are used to identify particular messages in a channel's history
|
||
|
* clients store "hashes" either in memory or in their drive to query for new messages:
|
||
|
* when reconnecting to a pad
|
||
|
* when connecting to chat or a mailbox
|
||
|
* thus, we can't change this function without invalidating client data which:
|
||
|
* is encrypted clientside
|
||
|
* can't be easily migrated
|
||
|
* don't break it!
|
||
|
*/
|
||
|
HK.getHash = function (msg, Log) {
|
||
|
if (typeof(msg) !== 'string') {
|
||
|
if (Log) {
|
||
|
Log.warn('HK_GET_HASH', 'getHash() called on ' + typeof(msg) + ': ' + msg);
|
||
|
}
|
||
|
return '';
|
||
|
}
|
||
|
return msg.slice(0,64);
|
||
|
};
|
||
|
|