Browse Source

Merge pull request #57 from stakwork/migrate-key

Migrate key
bugfix/timeout-logging v0.9.23
Evan Feenstra 5 years ago
committed by GitHub
parent
commit
170a4917d4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      api/controllers/contacts.ts
  2. 2
      api/helpers.ts
  3. 11
      dist/api/controllers/contacts.js
  4. 2
      dist/api/controllers/contacts.js.map
  5. 2
      dist/api/helpers.js
  6. 2
      dist/api/helpers.js.map

17
api/controllers/contacts.ts

@ -72,24 +72,19 @@ 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)
.filter(c=> c.id!==1 && c.publicKey).map(c=> c.id)
if (contactIds.length == 0) return
console.log("=> send contact_key to", contactIds)
helpers.sendContactKeys({
contactIds: contactIds,
sender: owner,

2
api/helpers.ts

@ -87,7 +87,7 @@ export const performKeysendMessage = async ({ destination_key, amount, msg, succ
// console.log("=> keysend to new contact")
if (success) success(r)
} catch (e) {
console.log("MESSAGE ERROR", e)
console.log("MESSAGE ERROR to", destination_key, e)
if (failure) failure(e)
}
}

11
dist/api/controllers/contacts.js

@ -68,19 +68,18 @@ 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);
.filter(c => c.id !== 1 && c.publicKey).map(c => c.id);
if (contactIds.length == 0)
return;
console.log("=> send contact_key to", contactIds);
helpers.sendContactKeys({
contactIds: contactIds,
sender: owner,

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

File diff suppressed because one or more lines are too long

2
dist/api/helpers.js

@ -94,7 +94,7 @@ exports.performKeysendMessage = ({ destination_key, amount, msg, success, failur
success(r);
}
catch (e) {
console.log("MESSAGE ERROR", e);
console.log("MESSAGE ERROR to", destination_key, e);
if (failure)
failure(e);
}

2
dist/api/helpers.js.map

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