Browse Source

allow to migrate contact_key

bugfix/timeout-logging
Evan Feenstra 5 years ago
parent
commit
8dd7fbad64
  1. 14
      api/controllers/contacts.ts
  2. 8
      dist/api/controllers/contacts.js
  3. 2
      dist/api/controllers/contacts.js.map

14
api/controllers/contacts.ts

@ -72,20 +72,14 @@ export const updateContact = async (req, res) => {
let attrs = extractAttrs(req.body)
const contact = await 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
const owner = await contact.update(jsonUtils.jsonToContact(attrs))
success(res, jsonUtils.contactToJson(owner))
if (!shouldSendUpdatedSelf) return
// send updated owner info to others
if (!contact.isOwner) return
// else:
// send updated owner info to others!
const contactIds = await models.Contact.findAll({where:{deleted:false}})
.filter(c=> !c.fromGroup && c.id!==1 && c.publicKey).map(c=> c.id)
if (contactIds.length == 0) return

8
dist/api/controllers/contacts.js

@ -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 });
let attrs = extractAttrs(req.body);
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
const owner = yield contact.update(jsonUtils.jsonToContact(attrs));
res_1.success(res, jsonUtils.contactToJson(owner));
if (!shouldSendUpdatedSelf)
if (!contact.isOwner)
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 } })
.filter(c => !c.fromGroup && c.id !== 1 && c.publicKey).map(c => c.id);
if (contactIds.length == 0)

2
dist/api/controllers/contacts.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save