mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Use a stable database ID for new list/source/issue mappings. Stop on creation conflicts without replacing moved cards or claiming successful reconciliation. Cover concurrent database writers, browser clients, moved-card recovery and unrelated database failures. Thanks to xet7.
13 lines
504 B
JavaScript
13 lines
504 B
JavaScript
const { createHash } = require('node:crypto');
|
|
|
|
// Keep a retry (including another worker) on the same database primary key.
|
|
// JSON tuple encoding avoids delimiter collisions in external IDs. Use the
|
|
// entire digest; this ID is an identity, never an authorization credential.
|
|
function listSyncCardId(listId, sourceKey, externalId) {
|
|
return `sync-${createHash('sha256')
|
|
.update(JSON.stringify([listId, sourceKey, String(externalId)]))
|
|
.digest('hex')}`;
|
|
}
|
|
|
|
module.exports = { listSyncCardId };
|