Browse Source

dont send to self

hosting-provider
Evan Feenstra 5 years ago
parent
commit
7ce58110ff
  1. 5
      api/controllers/contacts.ts
  2. 5
      dist/api/controllers/contacts.js
  3. 2
      dist/api/controllers/contacts.js.map

5
api/controllers/contacts.ts

@ -70,7 +70,6 @@ const updateContact = async (req, res) => {
console.log('=> updateContact called', { body: req.body, params: req.params, query: req.query })
let attrs = extractAttrs(req.body)
console.log("TO UPDATE",attrs)
const contact = await models.Contact.findOne({ where: { id: req.params.id }})
let shouldSendUpdatedSelf = (
@ -79,7 +78,6 @@ const updateContact = async (req, res) => {
attrs["contact_key"]==null // OR NO NEW CONTACT KEY
)
)
console.log('shouldSendUPdatedSelf',shouldSendUpdatedSelf)
// update self
const owner = await contact.update(jsonUtils.jsonToContact(attrs))
@ -89,8 +87,7 @@ const updateContact = async (req, res) => {
// send updated owner info to others
const contactIds = await models.Contact.findAll({where:{deleted:false}})
.filter(c=> !c.fromGroup).map(c=> c.id)
console.log('contactIds',contactIds)
.filter(c=> !c.fromGroup && c.id!==1 && c.publicKey).map(c=> c.id)
if (contactIds.length == 0) return
helpers.sendContactKeys({

5
dist/api/controllers/contacts.js

@ -69,12 +69,10 @@ exports.generateToken = generateToken;
const 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);
console.log("TO UPDATE", attrs);
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
));
console.log('shouldSendUPdatedSelf', shouldSendUpdatedSelf);
// update self
const owner = yield contact.update(jsonUtils.jsonToContact(attrs));
res_1.success(res, jsonUtils.contactToJson(owner));
@ -82,8 +80,7 @@ const updateContact = (req, res) => __awaiter(void 0, void 0, void 0, function*
return;
// send updated owner info to others
const contactIds = yield models_1.models.Contact.findAll({ where: { deleted: false } })
.filter(c => !c.fromGroup).map(c => c.id);
console.log('contactIds', contactIds);
.filter(c => !c.fromGroup && c.id !== 1 && c.publicKey).map(c => c.id);
if (contactIds.length == 0)
return;
helpers.sendContactKeys({

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

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