Browse Source

bot_res

push-params
Evan Feenstra 4 years ago
parent
commit
16c8fb125f
  1. 5
      api/controllers/actions.ts
  2. 30
      api/controllers/bots.ts
  3. 2
      dist/api/controllers/actions.js
  4. 2
      dist/api/controllers/actions.js.map
  5. 29
      dist/api/controllers/bots.js
  6. 2
      dist/api/controllers/bots.js.map

5
api/controllers/actions.ts

@ -126,6 +126,7 @@ export async function processAction(req, res) {
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)) {
@ -144,6 +145,7 @@ export async function finalActionProcess(a:Action){
} catch (e) {
throw e
}
} else if (action === 'broadcast') {
console.log('=> BOT BROADCAST')
if (!chatID || !text) throw 'no chatID or text'
@ -161,7 +163,7 @@ export async function finalActionProcess(a:Action){
const msg: { [k: string]: any } = {
chatId: theChat.id,
uuid: short.generate(),
type: constants.message_types.message,
type: constants.message_types.bot_res,
sender: owner.id,
amount: amount || 0,
date: date,
@ -187,6 +189,7 @@ export async function finalActionProcess(a:Action){
throw e
}
})
} else {
throw 'no action'
}

30
api/controllers/bots.ts

@ -1,10 +1,5 @@
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 {Action,finalActionProcess} from './actions'
const constants = require(path.join(__dirname, '../../config/constants.json'))
@ -16,29 +11,6 @@ async function broadcastAction(chat,text){
botName:'MotherBot'
}
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
@ -75,6 +47,8 @@ const botHelpHTML=`<div>
export function installBot(botname,botInTribe) {
console.log("INSTALL BOT NOW")
// search registry for bot (by name)
// need bot uuid and maker pubkey
// send bot_install to bot maker

2
dist/api/controllers/actions.js

@ -169,7 +169,7 @@ function finalActionProcess(a) {
const msg = {
chatId: theChat.id,
uuid: short.generate(),
type: constants.message_types.message,
type: constants.message_types.bot_res,
sender: owner.id,
amount: amount || 0,
date: date,

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

File diff suppressed because one or more lines are too long

29
dist/api/controllers/bots.js

@ -10,11 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
// 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 broadcastAction(chat, text) {
@ -25,29 +20,6 @@ function broadcastAction(chat, text) {
botName: 'MotherBot'
};
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
@ -86,6 +58,7 @@ const botHelpHTML = `<div>
/* intercept */
function installBot(botname, botInTribe) {
console.log("INSTALL BOT NOW");
// search registry for bot (by name)
// need bot uuid and maker pubkey
// send bot_install to bot maker
// generate ChatMember with bot=true

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;YACrB,OAAO,EAAC,WAAW;SACpB,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;QAChB,cAAc;QACd,eAAe;QACf,uCAAuC;QACvC,6BAA6B;QAC7B,yCAAyC;QACzC,oBAAoB;QACnB,qBAAqB;QACrB,6BAA6B;QAC7B,IAAI;QACJ,mDAAmD;QACnD,oBAAoB;QACrB,oBAAoB;QACpB,2DAA2D;QAC3D,KAAK;IACN,CAAC;CAAA;AAED,0CAA0C;AAC1C,SAAsB,iBAAiB,CAAC,GAAO,EAAE,IAAI,EAAE,UAAU;;QAC/D,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAA;QAC/B,IAAG,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAC;YACzB,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,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