Browse Source

better attribute checking on update self contact

dependabot/npm_and_yarn/ini-1.3.7
Evan Feenstra 4 years ago
parent
commit
ce8c4d2889
  1. 10
      dist/src/controllers/contacts.js
  2. 2
      dist/src/controllers/contacts.js.map
  3. 11
      src/controllers/contacts.ts

10
dist/src/controllers/contacts.js

@ -88,16 +88,12 @@ exports.updateContact = (req, res) => __awaiter(void 0, void 0, void 0, function
if (!(attrs['contact_key'] || attrs['alias'] || attrs['photo_url'])) {
return; // skip if not at least one of these
}
const contactKeyChanged = contact.contactKey !== attrs['contact_key'];
const aliasChanged = contact.alias !== attrs['alias'];
const photoChanged = contact.photoUrl !== attrs['photo_url'];
const contactKeyChanged = attrs['contact_key'] && contact.contactKey !== attrs['contact_key'];
const aliasChanged = attrs['alias'] && contact.alias !== attrs['alias'];
const photoChanged = attrs['photo_url'] && contact.photoUrl !== attrs['photo_url'];
if (!(contactKeyChanged || aliasChanged || photoChanged)) {
return;
}
console.log('contact.alias', contact.alias);
console.log("attrs['alias']", attrs['alias']);
console.log('===', contact.alias !== attrs['alias']);
return;
// send updated owner info to others!
const contactIds = yield models_1.models.Contact.findAll({ where: { deleted: false } })
.filter(c => c.id !== 1 && c.publicKey).map(c => c.id);

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

File diff suppressed because one or more lines are too long

11
src/controllers/contacts.ts

@ -91,18 +91,13 @@ export const updateContact = async (req, res) => {
if (!(attrs['contact_key'] || attrs['alias'] || attrs['photo_url'])) {
return // skip if not at least one of these
}
const contactKeyChanged = contact.contactKey!==attrs['contact_key']
const aliasChanged = contact.alias!==attrs['alias']
const photoChanged = contact.photoUrl!==attrs['photo_url']
const contactKeyChanged = attrs['contact_key'] && contact.contactKey!==attrs['contact_key']
const aliasChanged = attrs['alias'] && contact.alias!==attrs['alias']
const photoChanged = attrs['photo_url'] && contact.photoUrl!==attrs['photo_url']
if(!(contactKeyChanged || aliasChanged || photoChanged)) {
return
}
console.log('contact.alias',contact.alias)
console.log("attrs['alias']", attrs['alias'])
console.log('===', contact.alias!==attrs['alias'])
return
// send updated owner info to others!
const contactIds = await models.Contact.findAll({where:{deleted:false}})
.filter(c=> c.id!==1 && c.publicKey).map(c=> c.id)

Loading…
Cancel
Save