Browse Source

default keysend handle

push-params
Evan Feenstra 4 years ago
parent
commit
65d0086a83
  1. 5
      api/controllers/actions.ts
  2. 1
      api/controllers/bots.ts
  3. 16
      api/network/send.ts
  4. 5
      dist/api/controllers/actions.js
  5. 2
      dist/api/controllers/actions.js.map
  6. 1
      dist/api/controllers/bots.js
  7. 2
      dist/api/controllers/bots.js.map
  8. 22
      dist/api/network/send.js
  9. 2
      dist/api/network/send.js.map

5
api/controllers/actions.ts

@ -7,6 +7,7 @@ import * as rsa from '../crypto/rsa'
import * as crypto from 'crypto'
import * as jsonUtils from '../utils/json'
import * as tribes from '../utils/tribes'
import * as socket from '../utils/socket'
/*
hexdump -n 8 -e '4/4 "%08X" 1 "\n"' /dev/random
@ -172,6 +173,10 @@ export async function finalActionProcess(a:Action){
senderAlias: alias,
}
const message = await models.Message.create(msg)
socket.sendJson({
type: 'message',
response: jsonUtils.messageToJson(message, theChat, owner)
})
await network.sendMessage({
chat: theChat,
sender: { ...owner.dataValues, alias },

1
api/controllers/bots.ts

@ -13,6 +13,7 @@ async function broadcastAction(chat,text){
const a:Action = {
action:'broadcast',
text, chatID: chat.id,
botName:'MotherBot'
}
finalActionProcess(a)
// var date = new Date()

16
api/network/send.ts

@ -62,7 +62,7 @@ export async function sendMessage(params) {
}
}
let yes:any = null
let yes:any = true
let no:any = null
console.log('all contactIds',contactIds)
await asyncForEach(contactIds, async contactId => {
@ -100,12 +100,12 @@ export async function sendMessage(params) {
console.log("KEYSEND ERROR", e)
no = e
}
// await sleep(2)
await sleep(2)
})
if(yes){
if(success) success(yes)
} else {
if(no){
if(failure) failure(no)
} else {
if(success) success(yes)
}
}
@ -180,9 +180,9 @@ async function asyncForEach(array, callback) {
await callback(array[index], index, array);
}
}
// async function sleep(ms) {
// return new Promise(resolve => setTimeout(resolve, ms))
// }
async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
// function urlBase64FromHex(ascii){
// return Buffer.from(ascii,'hex').toString('base64').replace(/\//g, '_').replace(/\+/g, '-')

5
dist/api/controllers/actions.js

@ -18,6 +18,7 @@ const rsa = require("../crypto/rsa");
const crypto = require("crypto");
const jsonUtils = require("../utils/json");
const tribes = require("../utils/tribes");
const socket = require("../utils/socket");
/*
hexdump -n 8 -e '4/4 "%08X" 1 "\n"' /dev/random
hexdump -n 16 -e '4/4 "%08X" 1 "\n"' /dev/random
@ -180,6 +181,10 @@ function finalActionProcess(a) {
senderAlias: alias,
};
const message = yield models_1.models.Message.create(msg);
socket.sendJson({
type: 'message',
response: jsonUtils.messageToJson(message, theChat, owner)
});
yield network.sendMessage({
chat: theChat,
sender: Object.assign(Object.assign({}, owner.dataValues), { alias }),

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

File diff suppressed because one or more lines are too long

1
dist/api/controllers/bots.js

@ -22,6 +22,7 @@ function broadcastAction(chat, text) {
const a = {
action: 'broadcast',
text, chatID: chat.id,
botName: 'MotherBot'
};
actions_1.finalActionProcess(a);
// var date = new Date()

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

@ -1 +1 @@
{"version":3,"file":"bots.js","sourceRoot":"","sources":["../../../api/controllers/bots.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAA4B;AAE5B,sCAAsC;AACtC,uCAAuC;AACvC,qCAAqC;AACrC,4CAA4C;AAC5C,6CAA6C;AAC7C,uCAAmD;AAEnD,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,CAAA;AAE9E,SAAe,eAAe,CAAC,IAAI,EAAC,IAAI;;QACtC,MAAM,CAAC,GAAU;YACf,MAAM,EAAC,WAAW;YAClB,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;SACtB,CAAA;QACD,4BAAkB,CAAC,CAAC,CAAC,CAAA;QACrB,wBAAwB;QACxB,0BAA0B;QAC1B,2EAA2E;QAC3E,iEAAiE;QACjE,+BAA+B;QAChC,oBAAoB;QACpB,2BAA2B;QAC3B,0CAA0C;QAC1C,gBAAgB;Q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GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC9C,CAAC;CAAA;AAFD,sCAEC;AAED,SAAsB,aAAa,CAAC,OAAO;;QACzC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC9C,CAAC;CAAA;AAFD,sCAEC"}

22
dist/api/network/send.js

@ -67,7 +67,7 @@ function sendMessage(params) {
contactIds = tribeOwner ? [tribeOwner.id] : [];
}
}
let yes = null;
let yes = true;
let no = null;
console.log('all contactIds', contactIds);
yield asyncForEach(contactIds, (contactId) => __awaiter(this, void 0, void 0, function* () {
@ -102,16 +102,16 @@ function sendMessage(params) {
console.log("KEYSEND ERROR", e);
no = e;
}
// await sleep(2)
yield sleep(2);
}));
if (yes) {
if (success)
success(yes);
}
else {
if (no) {
if (failure)
failure(no);
}
else {
if (success)
success(yes);
}
});
}
exports.sendMessage = sendMessage;
@ -181,9 +181,11 @@ function asyncForEach(array, callback) {
}
});
}
// async function sleep(ms) {
// return new Promise(resolve => setTimeout(resolve, ms))
// }
function sleep(ms) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise(resolve => setTimeout(resolve, ms));
});
}
// function urlBase64FromHex(ascii){
// return Buffer.from(ascii,'hex').toString('base64').replace(/\//g, '_').replace(/\+/g, '-')
// }

2
dist/api/network/send.js.map

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