Browse Source

inclue role in botCmdKeysend to bot creator in remote bot

push-params
Evan Feenstra 4 years ago
parent
commit
540379ad7f
  1. 19
      api/controllers/bots.ts
  2. 2
      api/network/interfaces.ts
  3. 2
      api/network/send.ts
  4. 20
      dist/api/controllers/bots.js
  5. 2
      dist/api/controllers/bots.js.map
  6. 2
      dist/api/network/send.js
  7. 2
      dist/api/network/send.js.map

19
api/controllers/bots.ts

@ -104,7 +104,11 @@ export async function installBot(chat, bot_json) {
type: constants.message_types.bot_install,
bot_uuid: myBot.uuid,
message: {content:'', amount:0},
sender: {pub_key: owner.publicKey, alias: owner.alias},
sender: {
pub_key: owner.publicKey,
alias: owner.alias,
role: constants.chat_roles.owner
},
chat: {uuid:chat_uuid}
}, myBot, SphinxBot.MSG_TYPE.INSTALL)
}
@ -136,10 +140,11 @@ export async function keysendBotCmd(msg, b): Promise<boolean> {
b.botUuid, b.botMakerPubkey, amt,
msg.chat.uuid,
msg.message.content,
(msg.sender && msg.sender.role)
)
}
export async function botKeysend(msg_type, bot_uuid, botmaker_pubkey, amount, chat_uuid:string, content?:string): Promise<boolean> {
export async function botKeysend(msg_type, bot_uuid, botmaker_pubkey, amount, chat_uuid:string, content?:string, sender_role?:number): Promise<boolean> {
const owner = await models.Contact.findOne({ where: { isOwner: true } })
const dest = botmaker_pubkey
const MIN_SATS = 3
@ -150,10 +155,14 @@ export async function botKeysend(msg_type, bot_uuid, botmaker_pubkey, amount, ch
data: <network.Msg>{
type: msg_type,
bot_uuid,
chat: {uuid:chat_uuid},
message: {content: content||'', amount:amt},
sender: {pub_key: owner.publicKey, alias: owner.alias},
chat: {uuid:chat_uuid}
},
sender: {
pub_key: owner.publicKey,
alias: owner.alias,
role: sender_role||constants.chat_roles.reader
}
}
}
try {
await network.signAndSend(opts)

2
api/network/interfaces.ts

@ -11,6 +11,6 @@ export interface Msg {
sender: {
pub_key: string,
alias: string,
role?: number
role: number
}
}

2
api/network/send.ts

@ -57,7 +57,7 @@ export async function sendMessage(params) {
// console.log("SEND.TS isBotMsg")
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)

20
dist/api/controllers/bots.js

@ -112,7 +112,11 @@ function installBot(chat, bot_json) {
type: constants.message_types.bot_install,
bot_uuid: myBot.uuid,
message: { content: '', amount: 0 },
sender: { pub_key: owner.publicKey, alias: owner.alias },
sender: {
pub_key: owner.publicKey,
alias: owner.alias,
role: constants.chat_roles.owner
},
chat: { uuid: chat_uuid }
}, myBot, SphinxBot.MSG_TYPE.INSTALL);
}
@ -141,11 +145,11 @@ function keysendBotCmd(msg, b) {
return __awaiter(this, void 0, void 0, function* () {
const amount = msg.message.amount || 0;
const amt = Math.max(amount, b.pricePerUse);
return yield botKeysend(constants.message_types.bot_cmd, b.botUuid, b.botMakerPubkey, amt, msg.chat.uuid, msg.message.content);
return yield botKeysend(constants.message_types.bot_cmd, b.botUuid, b.botMakerPubkey, amt, msg.chat.uuid, msg.message.content, (msg.sender && msg.sender.role));
});
}
exports.keysendBotCmd = keysendBotCmd;
function botKeysend(msg_type, bot_uuid, botmaker_pubkey, amount, chat_uuid, content) {
function botKeysend(msg_type, bot_uuid, botmaker_pubkey, amount, chat_uuid, content, sender_role) {
return __awaiter(this, void 0, void 0, function* () {
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const dest = botmaker_pubkey;
@ -157,10 +161,14 @@ function botKeysend(msg_type, bot_uuid, botmaker_pubkey, amount, chat_uuid, cont
data: {
type: msg_type,
bot_uuid,
chat: { uuid: chat_uuid },
message: { content: content || '', amount: amt },
sender: { pub_key: owner.publicKey, alias: owner.alias },
chat: { uuid: chat_uuid }
},
sender: {
pub_key: owner.publicKey,
alias: owner.alias,
role: sender_role || constants.chat_roles.reader
}
}
};
try {
yield network.signAndSend(opts);

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

File diff suppressed because one or more lines are too long

2
dist/api/network/send.js

@ -61,7 +61,7 @@ function sendMessage(params) {
// console.log("SEND.TS isBotMsg")
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