|
@ -68,15 +68,13 @@ exports.updateContact = (req, res) => __awaiter(void 0, void 0, void 0, function |
|
|
console.log('=> updateContact called', { body: req.body, params: req.params, query: req.query }); |
|
|
console.log('=> updateContact called', { body: req.body, params: req.params, query: req.query }); |
|
|
let attrs = extractAttrs(req.body); |
|
|
let attrs = extractAttrs(req.body); |
|
|
const contact = yield models_1.models.Contact.findOne({ where: { id: req.params.id } }); |
|
|
const contact = yield models_1.models.Contact.findOne({ where: { id: req.params.id } }); |
|
|
let shouldSendUpdatedSelf = (contact.isOwner && ((contact.contactKey == null && attrs["contact_key"] != null) || // CREATE CONTACT KEY!
|
|
|
|
|
|
attrs["contact_key"] == null // OR NO NEW CONTACT KEY
|
|
|
|
|
|
)); |
|
|
|
|
|
// update self
|
|
|
// update self
|
|
|
const owner = yield contact.update(jsonUtils.jsonToContact(attrs)); |
|
|
const owner = yield contact.update(jsonUtils.jsonToContact(attrs)); |
|
|
res_1.success(res, jsonUtils.contactToJson(owner)); |
|
|
res_1.success(res, jsonUtils.contactToJson(owner)); |
|
|
if (!shouldSendUpdatedSelf) |
|
|
if (!contact.isOwner) |
|
|
return; |
|
|
return; |
|
|
// send updated owner info to others
|
|
|
// else:
|
|
|
|
|
|
// send updated owner info to others!
|
|
|
const contactIds = yield models_1.models.Contact.findAll({ where: { deleted: false } }) |
|
|
const contactIds = yield models_1.models.Contact.findAll({ where: { deleted: false } }) |
|
|
.filter(c => !c.fromGroup && c.id !== 1 && c.publicKey).map(c => c.id); |
|
|
.filter(c => !c.fromGroup && c.id !== 1 && c.publicKey).map(c => c.id); |
|
|
if (contactIds.length == 0) |
|
|
if (contactIds.length == 0) |
|
|