Browse Source

full forwarding loop from keysend to external bot, back to action route, to mqtt, forwarded to tribe again

push-params
Evan Feenstra 4 years ago
parent
commit
b060f83ac8
  1. 37
      api/controllers/actions.ts
  2. 100
      api/controllers/bots.ts
  3. 3
      api/models/ts/botMember.ts
  4. 11
      api/network/intercept.ts
  5. 15
      api/network/receive.ts
  6. 4
      api/utils/setup.ts
  7. 34
      dist/api/controllers/actions.js
  8. 2
      dist/api/controllers/actions.js.map
  9. 97
      dist/api/controllers/bots.js
  10. 2
      dist/api/controllers/bots.js.map
  11. 4
      dist/api/models/ts/botMember.js
  12. 2
      dist/api/models/ts/botMember.js.map
  13. 13
      dist/api/network/intercept.js
  14. 2
      dist/api/network/intercept.js.map
  15. 14
      dist/api/network/receive.js
  16. 2
      dist/api/network/receive.js.map
  17. 2
      dist/api/utils/setup.js
  18. 2
      dist/api/utils/setup.js.map

37
api/controllers/actions.ts

@ -6,6 +6,8 @@ import * as rsa from '../crypto/rsa'
import * as jsonUtils from '../utils/json'
import * as socket from '../utils/socket'
import { success, failure } from '../utils/res'
import * as tribes from '../utils/tribes'
/*
hexdump -n 8 -e '4/4 "%08X" 1 "\n"' /dev/random
@ -52,15 +54,40 @@ export async function processAction(req, res) {
}
try {
const r = await finalAction(a)
const r = await finalAction(a,bot_id)
success(res, r)
} catch(e) {
failure(res, e)
}
}
export async function finalAction(a:Action){
export async function finalAction(a:Action, bot_id:string){
const {action,pubkey,amount,content,bot_name,chat_uuid} = a
if (!chat_uuid) throw 'no chat_uuid'
const owner = await models.Contact.findOne({ where: { isOwner: true } })
let theChat = await models.Chat.findOne({ where: { uuid: chat_uuid } })
if(!theChat) {
// is this a bot member cmd res
const botMember = await models.BotMember.findOne({where:{
tribeUuid: chat_uuid, botId: bot_id
}})
if(!botMember) return console.log('no botMember')
const dest = botMember.memberPubkey
if(!dest) return console.log('no dest to send to')
const topic = `${dest}/${chat_uuid}`
const data = {
...a,
bot_id,
sender:{pub_key: owner.publicKey} // for verify sig
}
await tribes.publish(topic, data, function(){
})
return
}
if (action === 'keysend') {
console.log('=> BOT KEYSEND')
@ -83,10 +110,8 @@ export async function finalAction(a:Action){
} else if (action === 'broadcast') {
console.log('=> BOT BROADCAST')
if (!chat_uuid || !content) throw 'no chatID or content'
const owner = await models.Contact.findOne({ where: { isOwner: true } })
const theChat = await models.Chat.findOne({ where: { uuid: chat_uuid } })
if (!theChat || !owner) throw 'no chat'
if (!content) throw 'no content'
if (!theChat) throw 'no chat'
if (!theChat.type === constants.chat_types.tribe) throw 'not a tribe'
const encryptedForMeText = rsa.encrypt(owner.contactKey, content)

100
api/controllers/bots.ts

@ -5,6 +5,8 @@ import { models } from '../models'
import * as jsonUtils from '../utils/json'
import { success, failure } from '../utils/res'
import * as network from '../network'
import * as intercept from '../network/intercept'
import {finalAction} from './actions'
const constants = require(path.join(__dirname, '../../config/constants.json'))
@ -32,7 +34,7 @@ export const createBot = async (req, res) => {
try {
const owner = await models.Contact.findOne({ where: { isOwner: true } })
const theBot = await models.Bot.create(newBot)
// post to bots.sphinx.chat
// post to tribes.sphinx.chat
tribes.declare_bot({
uuid,
owner_pubkey: owner.publicKey,
@ -73,8 +75,8 @@ export async function installBot(chatId:number, bot_json) {
pricePerUse: price_per_use
}
console.log("installBot INSTALL BOT NOW",chatBot)
keysendBotInstall(chatBot)
await models.ChatBot.create(chatBot)
const succeeded = await keysendBotInstall(chatBot)
if(succeeded) models.ChatBot.create(chatBot)
}
export async function keysendBotInstall(b): Promise<boolean> {
@ -88,24 +90,12 @@ export async function keysendBotCmd(msg, b): Promise<boolean> {
return await botKeysend(
constants.message_types.bot_cmd,
b.botUuid, b.botMakerPubkey, b.pricePerUse,
msg.message.content
msg.message.content,
msg.chat.uuid,
)
}
export async function receiveBotInstall(payload) {
console.log('=> receiveBotInstall')
// const dat = payload.content || payload
// const sender_pub_key = dat.sender.pub_key
// const bot_uuid = dat.bot_uuid
// verify tribe ownership (verify signed timestamp)
// CHECK PUBKEY - is it me? install it! (create botmember)
// if the pubkey=the botOwnerPubkey, (create chatbot)
}
export async function botKeysend(msg_type, bot_uuid, botmaker_pubkey, price_per_use, content?:string): Promise<boolean> {
export async function botKeysend(msg_type, bot_uuid, botmaker_pubkey, price_per_use, content?:string, chat_uuid?:string): Promise<boolean> {
const owner = await models.Contact.findOne({ where: { isOwner: true } })
const MIN_SATS = 3
const destkey = botmaker_pubkey
@ -117,10 +107,14 @@ export async function botKeysend(msg_type, bot_uuid, botmaker_pubkey, price_per_
message: {content: content||''},
sender: {
pub_key: owner.publicKey,
}
},
chat: {}
},
amt: Math.max(price_per_use || MIN_SATS)
}
if(chat_uuid) {
opts.data.chat = {uuid:chat_uuid}
}
try {
await network.signAndSend(opts)
return true
@ -129,24 +123,70 @@ export async function botKeysend(msg_type, bot_uuid, botmaker_pubkey, price_per_
}
}
// type BotCmdType = 'install' | 'message' | 'broadcast' | 'keysend'
export async function receiveBotInstall(payload) {
console.log('=> receiveBotInstall',payload)
const dat = payload.content || payload
const sender_pub_key = dat.sender && dat.sender.pub_key
const bot_uuid = dat.bot_uuid
const chat_uuid = dat.chat && dat.chat.uuid
if(!chat_uuid || !sender_pub_key) return console.log('no chat uuid or sender pub key')
const owner = await models.Contact.findOne({ where: { isOwner: true } })
const bot = await models.Bot.findOne({where:{
uuid: bot_uuid
}})
if(!bot) return
const verifiedOwnerPubkey = await tribes.verifySignedTimestamp(bot_uuid)
if(verifiedOwnerPubkey===owner.publicKey){
const botMember = {
botId: bot.id,
memberPubkey:sender_pub_key,
tribeUuid:chat_uuid,
msgCount:0,
}
console.log("CREATE bot MEMBER", botMember)
await models.BotMember.create(botMember)
}
//- need to pub back MQTT bot_install??
//- and if the pubkey=the botOwnerPubkey, confirm chatbot?
}
export async function receiveBotCmd(payload) {
console.log("=> receiveBotCmd")
console.log(constants.message_types.bot_cmd)
// forward to the entire Action back
console.log("=> receiveBotCmd", payload)
// const dat = payload.content || payload
const dat = payload.content || payload
// const sender_pub_key = dat.sender.pub_key
// const bot_uuid = dat.bot_uuid
// const content = dat.message.content - check prefix
// const amount = dat.message.amount
const bot_uuid = dat.bot_uuid
const chat_uuid = dat.chat && dat.chat.uuid
if(!chat_uuid) return console.log('no chat uuid')
// const amount = dat.message.amount - check price_per_use
const bot = await models.Bot.findOne({where:{
uuid: bot_uuid
}})
if(!bot) return
const botMember = await models.BotMember.findOne({ where:{
botId: bot.id,
tribeUuid: chat_uuid,
}})
if(!botMember) return
botMember.update({ msgCount: (botMember||0)+1 })
console.log('=> post to remote BOT!!!!! bot owner')
return intercept.postToBotServer(payload, bot)
// forward to the entire Action back over MQTT
}
export async function receiveBotRes(payload) {
console.log("=> receiveBotRes")
console.log(constants.message_types.bot_res)
console.log("=> receiveBotRes", payload)
// forward to the tribe
// received the entire action?
const bot_id = payload.bot_id
finalAction(payload, bot_id)
}

3
api/models/ts/botMember.ts

@ -15,6 +15,9 @@ export default class BotMember extends Model<BotMember> {
})
id: number
@Column
botId: string
@Column
memberPubkey: string

11
api/network/intercept.ts

@ -62,7 +62,10 @@ async function emitMessageToBot(msg, botInTribe): Promise<boolean> {
builtinBotEmit(msg)
return true
case constants.bot_types.local:
return postToBotServer(msg, botInTribe)
const bot = await models.Bot.findOne({where:{
uuid: botInTribe.botUuid
}})
return postToBotServer(msg, bot)
case constants.bot_types.remote:
return keysendBotCmd(msg, botInTribe)
default:
@ -70,10 +73,8 @@ async function emitMessageToBot(msg, botInTribe): Promise<boolean> {
}
}
async function postToBotServer(msg, botInTribe): Promise<boolean> {
const bot = await models.Bot.findOne({where:{
uuid: botInTribe.botUuid
}})
export async function postToBotServer(msg, bot): Promise<boolean> {
if(!bot) return false
if(!bot.webhook || !bot.secret) return false
const r = await fetch(bot.webhook, {
method:'POST',

15
api/network/receive.ts

@ -11,7 +11,6 @@ import {modifyPayloadAndSaveMediaKey,purchaseFromOriginalSender,sendFinalMemeIfF
import {decryptMessage,encryptTribeBroadcast} from '../utils/msg'
import { Op } from 'sequelize'
import * as timers from '../utils/timers'
// import * as intercept from './intercept'
/*
delete type:
@ -34,14 +33,28 @@ const typesThatNeedPricePerMessage = [
export const typesToReplay=[ // should match typesToForward
msgtypes.message, msgtypes.group_join, msgtypes.group_leave
]
const botTypes=[
constants.message_types.bot_install,
constants.message_types.bot_cmd,
constants.message_types.bot_res
]
async function onReceive(payload){
console.log('===> onReceive',JSON.stringify(payload,null,2))
if(!payload.type) return console.log('no payload.type')
if(botTypes.includes(payload.type)) {
console.log("=> got bot msg type!!!!")
if(!payload.bot_uuid) return console.log('no bot uuid')
return ACTIONS[payload.type](payload)
}
// if tribe, owner must forward to MQTT
let doAction = true
const toAddIn:{[k:string]:any} = {}
let isTribe = false
let isTribeOwner = false
let chat
if(payload.chat&&payload.chat.uuid) {
isTribe = payload.chat.type===constants.chat_types.tribe
chat = await models.Chat.findOne({where:{uuid:payload.chat.uuid}})

4
api/utils/setup.ts

@ -69,6 +69,10 @@ async function migrate(){
)`)
} catch(e){}
addTableColumn('sphinx_bot_members', 'bot_id')
//////////
try{
await sequelize.query(`
CREATE TABLE sphinx_bots (

34
dist/api/controllers/actions.js

@ -17,6 +17,7 @@ const rsa = require("../crypto/rsa");
const jsonUtils = require("../utils/json");
const socket = require("../utils/socket");
const res_1 = require("../utils/res");
const tribes = require("../utils/tribes");
/*
hexdump -n 8 -e '4/4 "%08X" 1 "\n"' /dev/random
hexdump -n 16 -e '4/4 "%08X" 1 "\n"' /dev/random
@ -53,7 +54,7 @@ function processAction(req, res) {
bot_name: bot.name, chat_uuid
};
try {
const r = yield finalAction(a);
const r = yield finalAction(a, bot_id);
res_1.success(res, r);
}
catch (e) {
@ -62,9 +63,30 @@ function processAction(req, res) {
});
}
exports.processAction = processAction;
function finalAction(a) {
function finalAction(a, bot_id) {
return __awaiter(this, void 0, void 0, function* () {
const { action, pubkey, amount, content, bot_name, chat_uuid } = a;
if (!chat_uuid)
throw 'no chat_uuid';
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
let theChat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } });
if (!theChat) {
// is this a bot member cmd res
const botMember = yield models_1.models.BotMember.findOne({ where: {
tribeUuid: chat_uuid, botId: bot_id
} });
if (!botMember)
return console.log('no botMember');
const dest = botMember.memberPubkey;
if (!dest)
return console.log('no dest to send to');
const topic = `${dest}/${chat_uuid}`;
const data = Object.assign(Object.assign({}, a), { bot_id, sender: { pub_key: owner.publicKey } // for verify sig
});
yield tribes.publish(topic, data, function () {
});
return;
}
if (action === 'keysend') {
console.log('=> BOT KEYSEND');
if (!(pubkey && pubkey.length === 66 && amount)) {
@ -87,11 +109,9 @@ function finalAction(a) {
}
else if (action === 'broadcast') {
console.log('=> BOT BROADCAST');
if (!chat_uuid || !content)
throw 'no chatID or content';
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const theChat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } });
if (!theChat || !owner)
if (!content)
throw 'no content';
if (!theChat)
throw 'no chat';
if (!theChat.type === constants.chat_types.tribe)
throw 'not a tribe';

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

@ -1 +1 @@
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../api/controllers/actions.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAA4B;AAC5B,sCAAqC;AACrC,sCAAkC;AAClC,oCAAmC;AACnC,qCAAoC;AACpC,2CAA0C;AAC1C,0CAAyC;AACzC,sCAA+C;AAE/C;;;EAGE;AAEF,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,CAAA;AAW9E,SAAsB,aAAa,CAAC,GAAG,EAAE,GAAG;;QACxC,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;QACnB,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YACpE,IAAI,EAAE,uDAAuD;gBACzD,MAAM,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AAE;gBACjE,IAAI,EAAE,SAAS,CAAC,aAAa,CAAC,OAAO;gBACrC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAClC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACX,MAAM,CAAC,CAAA;gBACX,CAAC;aACJ,CAAC,CAAA;SAEL;aAAM;YACH,MAAM,WAAW,CAAA;SACpB;IACL,CAAC;CAAA;AA7FD,kCA6FC"}

97
dist/api/controllers/bots.js

@ -16,6 +16,8 @@ const models_1 = require("../models");
const jsonUtils = require("../utils/json");
const res_1 = require("../utils/res");
const network = require("../network");
const intercept = require("../network/intercept");
const actions_1 = require("./actions");
const constants = require(path.join(__dirname, '../../config/constants.json'));
exports.getBots = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
try {
@ -40,7 +42,7 @@ exports.createBot = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
try {
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const theBot = yield models_1.models.Bot.create(newBot);
// post to bots.sphinx.chat
// post to tribes.sphinx.chat
tribes.declare_bot({
uuid,
owner_pubkey: owner.publicKey,
@ -83,8 +85,9 @@ function installBot(chatId, bot_json) {
pricePerUse: price_per_use
};
console.log("installBot INSTALL BOT NOW", chatBot);
keysendBotInstall(chatBot);
yield models_1.models.ChatBot.create(chatBot);
const succeeded = yield keysendBotInstall(chatBot);
if (succeeded)
models_1.models.ChatBot.create(chatBot);
});
}
exports.installBot = installBot;
@ -96,23 +99,11 @@ function keysendBotInstall(b) {
exports.keysendBotInstall = keysendBotInstall;
function keysendBotCmd(msg, b) {
return __awaiter(this, void 0, void 0, function* () {
return yield botKeysend(constants.message_types.bot_cmd, b.botUuid, b.botMakerPubkey, b.pricePerUse, msg.message.content);
return yield botKeysend(constants.message_types.bot_cmd, b.botUuid, b.botMakerPubkey, b.pricePerUse, msg.message.content, msg.chat.uuid);
});
}
exports.keysendBotCmd = keysendBotCmd;
function receiveBotInstall(payload) {
return __awaiter(this, void 0, void 0, function* () {
console.log('=> receiveBotInstall');
// const dat = payload.content || payload
// const sender_pub_key = dat.sender.pub_key
// const bot_uuid = dat.bot_uuid
// verify tribe ownership (verify signed timestamp)
// CHECK PUBKEY - is it me? install it! (create botmember)
// if the pubkey=the botOwnerPubkey, (create chatbot)
});
}
exports.receiveBotInstall = receiveBotInstall;
function botKeysend(msg_type, bot_uuid, botmaker_pubkey, price_per_use, content) {
function botKeysend(msg_type, bot_uuid, botmaker_pubkey, price_per_use, content, chat_uuid) {
return __awaiter(this, void 0, void 0, function* () {
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const MIN_SATS = 3;
@ -125,10 +116,14 @@ function botKeysend(msg_type, bot_uuid, botmaker_pubkey, price_per_use, content)
message: { content: content || '' },
sender: {
pub_key: owner.publicKey,
}
},
chat: {}
},
amt: Math.max(price_per_use || MIN_SATS)
};
if (chat_uuid) {
opts.data.chat = { uuid: chat_uuid };
}
try {
yield network.signAndSend(opts);
return true;
@ -139,26 +134,72 @@ function botKeysend(msg_type, bot_uuid, botmaker_pubkey, price_per_use, content)
});
}
exports.botKeysend = botKeysend;
// type BotCmdType = 'install' | 'message' | 'broadcast' | 'keysend'
function receiveBotInstall(payload) {
return __awaiter(this, void 0, void 0, function* () {
console.log('=> receiveBotInstall', payload);
const dat = payload.content || payload;
const sender_pub_key = dat.sender && dat.sender.pub_key;
const bot_uuid = dat.bot_uuid;
const chat_uuid = dat.chat && dat.chat.uuid;
if (!chat_uuid || !sender_pub_key)
return console.log('no chat uuid or sender pub key');
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const bot = yield models_1.models.Bot.findOne({ where: {
uuid: bot_uuid
} });
if (!bot)
return;
const verifiedOwnerPubkey = yield tribes.verifySignedTimestamp(bot_uuid);
if (verifiedOwnerPubkey === owner.publicKey) {
const botMember = {
botId: bot.id,
memberPubkey: sender_pub_key,
tribeUuid: chat_uuid,
msgCount: 0,
};
console.log("CREATE bot MEMBER", botMember);
yield models_1.models.BotMember.create(botMember);
}
//- need to pub back MQTT bot_install??
//- and if the pubkey=the botOwnerPubkey, confirm chatbot?
});
}
exports.receiveBotInstall = receiveBotInstall;
function receiveBotCmd(payload) {
return __awaiter(this, void 0, void 0, function* () {
console.log("=> receiveBotCmd");
console.log(constants.message_types.bot_cmd);
// forward to the entire Action back
// const dat = payload.content || payload
console.log("=> receiveBotCmd", payload);
const dat = payload.content || payload;
// const sender_pub_key = dat.sender.pub_key
// const bot_uuid = dat.bot_uuid
// const content = dat.message.content - check prefix
// const amount = dat.message.amount
const bot_uuid = dat.bot_uuid;
const chat_uuid = dat.chat && dat.chat.uuid;
if (!chat_uuid)
return console.log('no chat uuid');
// const amount = dat.message.amount - check price_per_use
const bot = yield models_1.models.Bot.findOne({ where: {
uuid: bot_uuid
} });
if (!bot)
return;
const botMember = yield models_1.models.BotMember.findOne({ where: {
botId: bot.id,
tribeUuid: chat_uuid,
} });
if (!botMember)
return;
botMember.update({ msgCount: (botMember || 0) + 1 });
console.log('=> post to remote BOT!!!!! bot owner');
return intercept.postToBotServer(payload, bot);
// forward to the entire Action back over MQTT
});
}
exports.receiveBotCmd = receiveBotCmd;
function receiveBotRes(payload) {
return __awaiter(this, void 0, void 0, function* () {
console.log("=> receiveBotRes");
console.log(constants.message_types.bot_res);
console.log("=> receiveBotRes", payload);
// forward to the tribe
// received the entire action?
const bot_id = payload.bot_id;
actions_1.finalAction(payload, bot_id);
});
}
exports.receiveBotRes = receiveBotRes;

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

File diff suppressed because one or more lines are too long

4
dist/api/models/ts/botMember.js

@ -24,6 +24,10 @@ __decorate([
}),
__metadata("design:type", Number)
], BotMember.prototype, "id", void 0);
__decorate([
sequelize_typescript_1.Column,
__metadata("design:type", String)
], BotMember.prototype, "botId", void 0);
__decorate([
sequelize_typescript_1.Column,
__metadata("design:type", String)

2
dist/api/models/ts/botMember.js.map

@ -1 +1 @@
{"version":3,"file":"botMember.js","sourceRoot":"","sources":["../../../../api/models/ts/botMember.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAsE;AAEtE;;EAEE;AAGF,IAAqB,SAAS,GAA9B,MAAqB,SAAU,SAAQ,4BAAgB;CAyBtD,CAAA;AAjBC;IANC,6BAAM,CAAC;QACN,IAAI,EAAE,+BAAQ,CAAC,MAAM;QACrB,UAAU,EAAE,IAAI;QAChB,MAAM,EAAE,IAAI;QACZ,aAAa,EAAE,IAAI;KACpB,CAAC;;qCACQ;AAGV;IADC,6BAAM;;+CACa;AAGpB;IADC,6BAAM;;4CACU;AAGjB;IADC,6BAAM;;2CACS;AAGhB;IADC,6BAAM;8BACI,IAAI;4CAAA;AAGf;IADC,6BAAM;8BACI,IAAI;4CAAA;AAvBI,SAAS;IAD7B,4BAAK,CAAC,EAAC,SAAS,EAAE,oBAAoB,EAAE,WAAW,EAAE,IAAI,EAAC,CAAC;GACvC,SAAS,CAyB7B;kBAzBoB,SAAS"}
{"version":3,"file":"botMember.js","sourceRoot":"","sources":["../../../../api/models/ts/botMember.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAsE;AAEtE;;EAEE;AAGF,IAAqB,SAAS,GAA9B,MAAqB,SAAU,SAAQ,4BAAgB;CA4BtD,CAAA;AApBC;IANC,6BAAM,CAAC;QACN,IAAI,EAAE,+BAAQ,CAAC,MAAM;QACrB,UAAU,EAAE,IAAI;QAChB,MAAM,EAAE,IAAI;QACZ,aAAa,EAAE,IAAI;KACpB,CAAC;;qCACQ;AAGV;IADC,6BAAM;;wCACM;AAGb;IADC,6BAAM;;+CACa;AAGpB;IADC,6BAAM;;4CACU;AAGjB;IADC,6BAAM;;2CACS;AAGhB;IADC,6BAAM;8BACI,IAAI;4CAAA;AAGf;IADC,6BAAM;8BACI,IAAI;4CAAA;AA1BI,SAAS;IAD7B,4BAAK,CAAC,EAAC,SAAS,EAAE,oBAAoB,EAAE,WAAW,EAAE,IAAI,EAAC,CAAC;GACvC,SAAS,CA4B7B;kBA5BoB,SAAS"}

13
dist/api/network/intercept.js

@ -71,7 +71,10 @@ function emitMessageToBot(msg, botInTribe) {
bots_1.builtinBotEmit(msg);
return true;
case constants.bot_types.local:
return postToBotServer(msg, botInTribe);
const bot = yield models_1.models.Bot.findOne({ where: {
uuid: botInTribe.botUuid
} });
return postToBotServer(msg, bot);
case constants.bot_types.remote:
return bots_2.keysendBotCmd(msg, botInTribe);
default:
@ -79,11 +82,10 @@ function emitMessageToBot(msg, botInTribe) {
}
});
}
function postToBotServer(msg, botInTribe) {
function postToBotServer(msg, bot) {
return __awaiter(this, void 0, void 0, function* () {
const bot = yield models_1.models.Bot.findOne({ where: {
uuid: botInTribe.botUuid
} });
if (!bot)
return false;
if (!bot.webhook || !bot.secret)
return false;
const r = yield node_fetch_1.default(bot.webhook, {
@ -97,6 +99,7 @@ function postToBotServer(msg, botInTribe) {
return r.ok;
});
}
exports.postToBotServer = postToBotServer;
function asyncForEach(array, callback) {
return __awaiter(this, void 0, void 0, function* () {
for (let index = 0; index < array.length; index++) {

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

@ -1 +1 @@
{"version":3,"file":"intercept.js","sourceRoot":"","sources":["../../../api/network/intercept.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,sCAAkC;AAClC,kCAAsD;AACtD,8CAAiD;AACjD,6BAA4B;AAC5B,2CAA8B;AAE9B,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,6BAA6B,CAAC,CAAC,CAAA;AAE7E;;;EAGE;AAEF,kDAAkD;AAClD,SAAsB,QAAQ,CAAC,GAAO,EAAE,QAAgB;;QACtD,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAA;QAC/B,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAA;QACxB,IAAG,OAAO,KAAG,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE;YAC5C,OAAO,KAAK,CAAA,CAAC,sCAAsC;SACpD;QACD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S,CAAC,SAAS,CAAC,MAAM;gBAC7B,OAAO,oBAAa,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;YACvC;gBACE,OAAO,KAAK,CAAA;SACf;IACH,CAAC;CAAA;AAED,SAAsB,eAAe,CAAC,GAAG,EAAE,GAAG;;QAC5C,IAAG,CAAC,GAAG;YAAE,OAAO,KAAK,CAAA;QACrB,IAAG,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM;YAAE,OAAO,KAAK,CAAA;QAC5C,MAAM,CAAC,GAAG,MAAM,oBAAK,CAAC,GAAG,CAAC,OAAO,EAAE;YACjC,MAAM,EAAC,MAAM;YACb,IAAI,EAAC,IAAI,CAAC,SAAS,CACjB,sBAAe,CAAC,GAAG,CAAC,CACrB;YACD,OAAO,EAAC;gBACN,UAAU,EAAE,GAAG,CAAC,MAAM;gBACtB,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAA;QACF,OAAO,CAAC,CAAC,EAAE,CAAA;IACb,CAAC;CAAA;AAdD,0CAcC;AAED,SAAe,YAAY,CAAC,KAAK,EAAE,QAAQ;;QAC1C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACjD,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;SAC5C;IACF,CAAC;CAAA"}

14
dist/api/network/receive.js

@ -22,7 +22,6 @@ const modify_1 = require("./modify");
const msg_1 = require("../utils/msg");
const sequelize_1 = require("sequelize");
const timers = require("../utils/timers");
// import * as intercept from './intercept'
/*
delete type:
owner needs to check that the delete is the one who made the msg
@ -42,9 +41,22 @@ const typesThatNeedPricePerMessage = [
exports.typesToReplay = [
msgtypes.message, msgtypes.group_join, msgtypes.group_leave
];
const botTypes = [
constants.message_types.bot_install,
constants.message_types.bot_cmd,
constants.message_types.bot_res
];
function onReceive(payload) {
return __awaiter(this, void 0, void 0, function* () {
console.log('===> onReceive', JSON.stringify(payload, null, 2));
if (!payload.type)
return console.log('no payload.type');
if (botTypes.includes(payload.type)) {
console.log("=> got bot msg type!!!!");
if (!payload.bot_uuid)
return console.log('no bot uuid');
return controllers_1.ACTIONS[payload.type](payload);
}
// if tribe, owner must forward to MQTT
let doAction = true;
const toAddIn = {};

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

File diff suppressed because one or more lines are too long

2
dist/api/utils/setup.js

@ -80,6 +80,8 @@ function migrate() {
)`);
}
catch (e) { }
addTableColumn('sphinx_bot_members', 'bot_id');
//////////
try {
yield models_1.sequelize.query(`
CREATE TABLE sphinx_bots (

2
dist/api/utils/setup.js.map

@ -1 +1 @@
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../api/utils/setup.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAA2C;AAC3C,sCAA2C;AAC3C,iDAAoC;AACpC,iCAAgC;AAChC,sCAAqC;AACrC,gDAAwC;AACxC,8CAA0D;AAE1D,MAAM,YAAY,GAAG,CAAC,CAAA;AAEtB,MAAM,aAAa,GAAG,GAAS,EAAE;IAC/B,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;IACxC,MAAM,UAAU,EAAE,CAAA;IAClB,IAAI;QACF,MAAM,kBAAS,CAAC,IAAI,EAAE,CAAA;QACtB,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;KACpC;IAAC,OAAM,CAAC,EAAE;QACT,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAC,CAAC,CAAC,CAAA;KAChC;IACD,MAAM,OAAO,EAAE,CAAA;IACf,iBAAiB,EAAE,CAAA;IACnB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AACnC,CAAC,CAAA,CAAA;AAsJQ,sCAAa;AApJtB,SAAe,UAAU;;QACvB,IAAI;YACF,MAAM,kBAAS,CAAC,KAAK,CAAC,yBAAyB,YAAY,EAAE,CAAC,CAAA;SAC/D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