Browse Source

tie bots to actions

push-params
Evan Feenstra 4 years ago
parent
commit
f3884f81d1
  1. 49
      api/controllers/actions.ts
  2. 64
      api/controllers/bots.ts
  3. 2
      api/network/intercept.ts
  4. 2
      api/network/receive.ts
  5. 2
      api/network/send.ts
  6. 45
      dist/api/controllers/actions.js
  7. 2
      dist/api/controllers/actions.js.map
  8. 64
      dist/api/controllers/bots.js
  9. 2
      dist/api/controllers/bots.js.map
  10. 1
      dist/api/network/intercept.js
  11. 2
      dist/api/network/intercept.js.map
  12. 2
      dist/api/network/receive.js
  13. 2
      dist/api/network/receive.js.map
  14. 2
      dist/api/network/send.js
  15. 2
      dist/api/network/send.js.map

49
api/controllers/actions.ts

@ -78,6 +78,15 @@ export const deleteBot = async (req, res) => {
}
}
export interface Action {
action: string
chatID: number,
botName?: string
amount?: number
pubkey?: string
text?: string
}
export async function processAction(req, res) {
let body = req.body
if (body.data && typeof body.data === 'string' && body.data[1] === "'") {
@ -100,10 +109,26 @@ export async function processAction(req, res) {
return failure(res, 'no action')
}
const a:Action = {
action, pubkey, text, amount,
botName:bot.name, chatID: bot.chatId
}
try {
const r = await finalActionProcess(a)
success(res, r)
} catch(e) {
failure(res, e)
}
}
export async function finalActionProcess(a:Action){
const {action,pubkey,amount,text,botName,chatID} = a
if (action === 'keysend') {
console.log('=> BOT KEYSEND')
if (!(pubkey && pubkey.length === 66 && amount)) {
return failure(res, 'wrong params')
throw 'wrong params'
}
const MIN_SATS = 3
const destkey = pubkey
@ -114,24 +139,24 @@ export async function processAction(req, res) {
}
try {
await network.signAndSend(opts)
return success(res, { success: true })
return ({ success: true })
} catch (e) {
return failure(res, e)
throw e
}
} else if (action === 'broadcast') {
console.log('=> BOT BROADCAST')
if (!bot.chatId || !text) return failure(res, 'no uuid or text')
if (!chatID || !text) throw 'no chatID or text'
const owner = await models.Contact.findOne({ where: { isOwner: true } })
const theChat = await models.Chat.findOne({ where: { id: bot.chatId } })
if (!theChat || !owner) return failure(res, 'no chat')
if (!theChat.type === constants.chat_types.tribe) return failure(res, 'not a tribe')
const theChat = await models.Chat.findOne({ where: { id: chatID } })
if (!theChat || !owner) throw 'no chat'
if (!theChat.type === constants.chat_types.tribe) throw 'not a tribe'
const encryptedForMeText = rsa.encrypt(owner.contactKey, text)
const encryptedText = rsa.encrypt(theChat.groupKey, text)
const textMap = { 'chat': encryptedText }
var date = new Date();
date.setMilliseconds(0)
const alias = bot.name || 'Bot'
const alias = botName || 'Bot'
const msg: { [k: string]: any } = {
chatId: theChat.id,
uuid: short.generate(),
@ -152,10 +177,12 @@ export async function processAction(req, res) {
sender: { ...owner.dataValues, alias },
message: { content: textMap, id: message.id, uuid: message.uuid },
type: constants.message_types.message,
success: () => success(res, { success: true }),
failure: () => failure(res, 'failed'),
success: () => ({ success: true }),
failure: () => {
throw 'publish failed'
}
})
} else {
return failure(res, 'no action')
throw 'no action'
}
}

64
api/controllers/bots.ts

@ -1,37 +1,43 @@
import * as path from 'path'
import {Msg} from '../network/interfaces'
import * as short from 'short-uuid'
import * as rsa from '../crypto/rsa'
import { models } from '../models'
import * as socket from '../utils/socket'
import * as jsonUtils from '../utils/json'
// import * as short from 'short-uuid'
// import * as rsa from '../crypto/rsa'
// import { models } from '../models'
// import * as socket from '../utils/socket'
// import * as jsonUtils from '../utils/json'
import {Action,finalActionProcess} from './actions'
const constants = require(path.join(__dirname, '../../config/constants.json'))
async function genBotRes(chat,text){
var date = new Date()
date.setMilliseconds(0)
const owner = await models.Contact.findOne({ where: { isOwner: true } })
const encryptedForMeText = rsa.encrypt(owner.contactKey, text)
const msg:{[k:string]:any}={
chatId: chat.id,
uuid: short.generate(),
type: constants.message_types.bot_res,
sender: -99,
amount: 0,
date: date,
messageContent: encryptedForMeText,
remoteMessageContent: '',
status: constants.statuses.confirmed,
createdAt: date,
updatedAt: date,
senderAlias: 'MotherBot'
async function broadcastAction(chat,text){
const a:Action = {
action:'broadcast',
text, chatID: chat.id,
}
const message = await models.Message.create(msg)
socket.sendJson({
type: 'message',
response: jsonUtils.messageToJson(message, chat, owner)
})
finalActionProcess(a)
// var date = new Date()
// date.setMilliseconds(0)
// const owner = await models.Contact.findOne({ where: { isOwner: true } })
// const encryptedForMeText = rsa.encrypt(owner.contactKey, text)
// const msg:{[k:string]:any}={
// chatId: chat.id,
// uuid: short.generate(),
// type: constants.message_types.bot_res,
// sender: -99,
// amount: 0,
// date: date,
// messageContent: encryptedForMeText,
// remoteMessageContent: '',
// status: constants.statuses.confirmed,
// createdAt: date,
// updatedAt: date,
// senderAlias: 'MotherBot'
// }
// const message = await models.Message.create(msg)
// socket.sendJson({
// type: 'message',
// response: jsonUtils.messageToJson(message, chat, owner)
// })
}
// return whether this is legit to process
@ -47,7 +53,7 @@ export async function processBotMessage(msg:Msg, chat, botInTribe): Promise<bool
installBot(arr[2], botInTribe)
return true
default:
genBotRes(chat,botHelpHTML)
broadcastAction(chat,botHelpHTML)
}
} else {

2
api/network/intercept.ts

@ -2,6 +2,7 @@ import {processBotMessage} from '../controllers/bots'
import {Msg} from './interfaces'
import { models } from '../models'
// return bool whether to skip forwarding to tribe
export async function isBotMsg(msg:Msg, sentByMe:boolean): Promise<boolean> {
const txt = msg.message.content
const chat = await models.Chat.findOne({where:{
@ -9,7 +10,6 @@ export async function isBotMsg(msg:Msg, sentByMe:boolean): Promise<boolean> {
}})
if(!chat) return false
if(txt.startsWith('/bot ')) {
const ok = processBotMessage(msg, chat, null)
return ok?true:false

2
api/network/receive.ts

@ -133,7 +133,7 @@ async function doTheAction(data){
const pld = await decryptMessage(data, chat)
const isBotMsg = await intercept.isBotMsg(pld, false)
if(isBotMsg===true) {
return // DO NOT FORWARD TO TRIBE, forwarded to bot instead
// return // DO NOT FORWARD TO TRIBE, forwarded to bot instead
}
const me = await models.Contact.findOne({where:{isOwner:true}})
payload = await encryptTribeBroadcast(pld, me, true) // true=isTribeOwner

2
api/network/send.ts

@ -51,7 +51,7 @@ export async function sendMessage(params) {
msg = await decryptMessage(msg, chat)
const isBotMsg = await intercept.isBotMsg(msg, true)
if(isBotMsg===true) {
return // DO NOT FORWARD TO TRIBE, forwarded to bot instead
// return // DO NOT FORWARD TO TRIBE, forwarded to bot instead
}
// post last_active to tribes server
tribes.putActivity(chat.uuid, chat.host)

45
dist/api/controllers/actions.js

@ -112,10 +112,27 @@ function processAction(req, res) {
if (!action) {
return res_1.failure(res, 'no action');
}
const a = {
action, pubkey, text, amount,
botName: bot.name, chatID: bot.chatId
};
try {
const r = yield finalActionProcess(a);
res_1.success(res, r);
}
catch (e) {
res_1.failure(res, e);
}
});
}
exports.processAction = processAction;
function finalActionProcess(a) {
return __awaiter(this, void 0, void 0, function* () {
const { action, pubkey, amount, text, botName, chatID } = a;
if (action === 'keysend') {
console.log('=> BOT KEYSEND');
if (!(pubkey && pubkey.length === 66 && amount)) {
return res_1.failure(res, 'wrong params');
throw 'wrong params';
}
const MIN_SATS = 3;
const destkey = pubkey;
@ -126,28 +143,28 @@ function processAction(req, res) {
};
try {
yield network.signAndSend(opts);
return res_1.success(res, { success: true });
return ({ success: true });
}
catch (e) {
return res_1.failure(res, e);
throw e;
}
}
else if (action === 'broadcast') {
console.log('=> BOT BROADCAST');
if (!bot.chatId || !text)
return res_1.failure(res, 'no uuid or text');
if (!chatID || !text)
throw 'no chatID or text';
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const theChat = yield models_1.models.Chat.findOne({ where: { id: bot.chatId } });
const theChat = yield models_1.models.Chat.findOne({ where: { id: chatID } });
if (!theChat || !owner)
return res_1.failure(res, 'no chat');
throw 'no chat';
if (!theChat.type === constants.chat_types.tribe)
return res_1.failure(res, 'not a tribe');
throw 'not a tribe';
const encryptedForMeText = rsa.encrypt(owner.contactKey, text);
const encryptedText = rsa.encrypt(theChat.groupKey, text);
const textMap = { 'chat': encryptedText };
var date = new Date();
date.setMilliseconds(0);
const alias = bot.name || 'Bot';
const alias = botName || 'Bot';
const msg = {
chatId: theChat.id,
uuid: short.generate(),
@ -168,14 +185,16 @@ function processAction(req, res) {
sender: Object.assign(Object.assign({}, owner.dataValues), { alias }),
message: { content: textMap, id: message.id, uuid: message.uuid },
type: constants.message_types.message,
success: () => res_1.success(res, { success: true }),
failure: () => res_1.failure(res, 'failed'),
success: () => ({ success: true }),
failure: () => {
throw 'publish failed';
}
});
}
else {
return res_1.failure(res, 'no action');
throw 'no action';
}
});
}
exports.processAction = processAction;
exports.finalActionProcess = finalActionProcess;
//# sourceMappingURL=actions.js.map

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

File diff suppressed because one or more lines are too long

64
dist/api/controllers/bots.js

@ -10,37 +10,43 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const short = require("short-uuid");
const rsa = require("../crypto/rsa");
const models_1 = require("../models");
const socket = require("../utils/socket");
const jsonUtils = require("../utils/json");
// import * as short from 'short-uuid'
// import * as rsa from '../crypto/rsa'
// import { models } from '../models'
// import * as socket from '../utils/socket'
// import * as jsonUtils from '../utils/json'
const actions_1 = require("./actions");
const constants = require(path.join(__dirname, '../../config/constants.json'));
function genBotRes(chat, text) {
function broadcastAction(chat, text) {
return __awaiter(this, void 0, void 0, function* () {
var date = new Date();
date.setMilliseconds(0);
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const encryptedForMeText = rsa.encrypt(owner.contactKey, text);
const msg = {
chatId: chat.id,
uuid: short.generate(),
type: constants.message_types.bot_res,
sender: -99,
amount: 0,
date: date,
messageContent: encryptedForMeText,
remoteMessageContent: '',
status: constants.statuses.confirmed,
createdAt: date,
updatedAt: date,
senderAlias: 'MotherBot'
const a = {
action: 'broadcast',
text, chatID: chat.id,
};
const message = yield models_1.models.Message.create(msg);
socket.sendJson({
type: 'message',
response: jsonUtils.messageToJson(message, chat, owner)
});
actions_1.finalActionProcess(a);
// var date = new Date()
// date.setMilliseconds(0)
// const owner = await models.Contact.findOne({ where: { isOwner: true } })
// const encryptedForMeText = rsa.encrypt(owner.contactKey, text)
// const msg:{[k:string]:any}={
// chatId: chat.id,
// uuid: short.generate(),
// type: constants.message_types.bot_res,
// sender: -99,
// amount: 0,
// date: date,
// messageContent: encryptedForMeText,
// remoteMessageContent: '',
// status: constants.statuses.confirmed,
// createdAt: date,
// updatedAt: date,
// senderAlias: 'MotherBot'
// }
// const message = await models.Message.create(msg)
// socket.sendJson({
// type: 'message',
// response: jsonUtils.messageToJson(message, chat, owner)
// })
});
}
// return whether this is legit to process
@ -59,7 +65,7 @@ function processBotMessage(msg, chat, botInTribe) {
installBot(arr[2], botInTribe);
return true;
default:
genBotRes(chat, botHelpHTML);
broadcastAction(chat, botHelpHTML);
}
}
else {

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,oCAAmC;AACnC,qCAAoC;AACpC,sCAAkC;AAClC,0CAAyC;AACzC,2CAA0C;AAE1C,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,CAAA;AAE9E,SAAe,SAAS,CAAC,IAAI,EAAC,IAAI;;QAChC,IAAI,IAAI,GAAG,IAAI,IAAI,EAAE,CAAA;QACrB,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;QACvB,MAAM,KAAK,GAAG,MAAM,eAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;QACxE,MAAM,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QAC9D,MAAM,GAAG,GAAkB;YAC3B,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE;YACtB,IAAI,EAAE,SAAS,CAAC,aAAa,CAAC,OAAO;YACrC,MA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AAPD,gCAOC;AAED,SAAsB,iBAAiB,CAAC,OAAO;;QAC7C,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;QACnC,yCAAyC;QACzC,4CAA4C;QAC5C,mCAAmC;QAEnC,mDAAmD;QAEnD,0CAA0C;IAC5C,CAAC;CAAA;AATD,8CASC;AAED,oEAAoE;AAEpE,SAAsB,aAAa,CAAC,OAAO;;QACzC,OAAO,CAAC,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"}

1
dist/api/network/intercept.js

@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", { value: true });
const bots_1 = require("../controllers/bots");
const models_1 = require("../models");
// return bool whether to skip forwarding to tribe
function isBotMsg(msg, sentByMe) {
return __awaiter(this, void 0, void 0, function* () {
const txt = msg.message.content;

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

@ -1 +1 @@
{"version":3,"file":"intercept.js","sourceRoot":"","sources":["../../../api/network/intercept.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,8CAAqD;AAErD,sCAAkC;AAElC,SAAsB,QAAQ,CAAC,GAAO,EAAE,QAAgB;;QACtD,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAA;QAC/B,MAAM,IAAI,GAAG,MAAM,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAC,KAAK,EAAC;gBAC5C,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI;aACpB,EAAC,CAAC,CAAA;QACH,IAAG,CAAC,IAAI;YAAE,OAAO,KAAK,CAAA;QAGtB,IAAG,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAA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,IAAI;YAAE,OAAO,KAAK,CAAA;QAEtB,IAAG,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;YAC1B,MAAM,EAAE,GAAG,wBAAiB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;YAC7C,OAAO,EAAE,CAAA,CAAC,CAAA,IAAI,CAAA,CAAC,CAAA,KAAK,CAAA;SACrB;QAED,MAAM,UAAU,GAAG,MAAM,eAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAC,KAAK,EAAC;gBACxD,GAAG,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;aAC1B,EAAC,CAAC,CAAA;QACH,IAAG,CAAC,UAAU;YAAE,OAAO,KAAK,CAAA;QAC5B,IAAG,CAAC,CAAC,UAAU,CAAC,cAAc,IAAI,UAAU,CAAC,OAAO,CAAC;YAAE,OAAO,KAAK,CAAA;QAEnE,IAAG,GAAG,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,SAAS,GAAG,CAAC,EAAC;YAC5C,MAAM,EAAE,GAAG,MAAM,wBAAiB,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;YACzD,OAAO,EAAE,CAAA,CAAC,CAAA,IAAI,CAAA,CAAC,CAAA,KAAK,CAAA;SACrB;QAED,OAAO,KAAK,CAAA;QAEZ,mBAAmB;QACnB,0CAA0C;QAE1C,uBAAuB;IACzB,CAAC;CAAA;AA7BD,4BA6BC"}

2
dist/api/network/receive.js

@ -152,7 +152,7 @@ function doTheAction(data) {
const pld = yield msg_1.decryptMessage(data, chat);
const isBotMsg = yield intercept.isBotMsg(pld, false);
if (isBotMsg === true) {
return; // DO NOT FORWARD TO TRIBE, forwarded to bot instead
// return // DO NOT FORWARD TO TRIBE, forwarded to bot instead
}
const me = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
payload = yield msg_1.encryptTribeBroadcast(pld, me, true); // true=isTribeOwner

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

File diff suppressed because one or more lines are too long

2
dist/api/network/send.js

@ -56,7 +56,7 @@ function sendMessage(params) {
msg = yield msg_1.decryptMessage(msg, chat);
const isBotMsg = yield intercept.isBotMsg(msg, true);
if (isBotMsg === true) {
return; // DO NOT FORWARD TO TRIBE, forwarded to bot instead
// return // DO NOT FORWARD TO TRIBE, forwarded to bot instead
}
// post last_active to tribes server
tribes.putActivity(chat.uuid, chat.host);

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

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