Browse Source

Merge pull request #80 from stakwork/rolez

Rolez
push-params
Evan Feenstra 4 years ago
committed by GitHub
parent
commit
6bda93eacd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      api/controllers/actions.ts
  2. 1
      api/controllers/chatTribes.ts
  3. 2
      api/controllers/messages.ts
  4. 2
      api/network/intercept.ts
  5. 12
      api/network/modify.ts
  6. 3
      api/network/receive.ts
  7. 19
      api/network/send.ts
  8. 5
      dist/api/controllers/actions.js
  9. 2
      dist/api/controllers/actions.js.map
  10. 2
      dist/api/controllers/chatTribes.js
  11. 2
      dist/api/controllers/chatTribes.js.map
  12. 2
      dist/api/controllers/messages.js.map
  13. 2
      dist/api/network/intercept.js
  14. 2
      dist/api/network/intercept.js.map
  15. 10
      dist/api/network/modify.js
  16. 2
      dist/api/network/modify.js.map
  17. 3
      dist/api/network/receive.js
  18. 2
      dist/api/network/receive.js.map
  19. 18
      dist/api/network/send.js
  20. 2
      dist/api/network/send.js.map

5
api/controllers/actions.ts

@ -162,13 +162,14 @@ export async function finalAction(a:Action, bot_id:string){
}) })
await network.sendMessage({ await network.sendMessage({
chat: theChat, chat: theChat,
sender: { ...owner.dataValues, alias, id:botContactId }, sender: { ...owner.dataValues, alias, id:botContactId, role: constants.chat_roles.reader },
message: { content: textMap, id: message.id, uuid: message.uuid }, message: { content: textMap, id: message.id, uuid: message.uuid },
type: constants.message_types.bot_res, type: constants.message_types.bot_res,
success: () => ({ success: true }), success: () => ({ success: true }),
failure: (e) => { failure: (e) => {
throw e throw e
} },
isForwarded: true,
}) })
} else { } else {

1
api/controllers/chatTribes.ts

@ -420,6 +420,7 @@ export async function replayChatHistory(chat, contact) {
const sender = { const sender = {
...owner.dataValues, ...owner.dataValues,
...m.senderAlias && {alias: m.senderAlias}, ...m.senderAlias && {alias: m.senderAlias},
role: constants.chat_roles.reader,
} }
let content = '' let content = ''
try {content = JSON.parse(m.remoteMessageContent)} catch(e) {} try {content = JSON.parse(m.remoteMessageContent)} catch(e) {}

2
api/controllers/messages.ts

@ -161,7 +161,7 @@ export const sendMessage = async (req, res) => {
reply_uuid, reply_uuid,
} = req.body } = req.body
var date = new Date(); var date = new Date()
date.setMilliseconds(0) date.setMilliseconds(0)
const owner = await models.Contact.findOne({ where: { isOwner: true }}) const owner = await models.Contact.findOne({ where: { isOwner: true }})

2
api/network/intercept.ts

@ -69,7 +69,7 @@ export async function isBotMsg(msg: Msg, sentByMe: boolean): Promise<boolean> {
} }
async function emitMessageToBot(msg, botInTribe): Promise<boolean> { async function emitMessageToBot(msg, botInTribe): Promise<boolean> {
// console.log('emitMessageToBot',msg) console.log('=> emitMessageToBot',JSON.stringify(msg,null,2))
switch (botInTribe.botType) { switch (botInTribe.botType) {
case constants.bot_types.builtin: case constants.bot_types.builtin:
builtinBotEmit(msg) builtinBotEmit(msg)

12
api/network/modify.ts

@ -84,13 +84,15 @@ export async function purchaseFromOriginalSender(payload, chat, purchaser){
chat: {...chat.dataValues, contactIds:[ogmsg.sender]}, chat: {...chat.dataValues, contactIds:[ogmsg.sender]},
sender: { sender: {
...owner.dataValues, ...owner.dataValues,
...purchaser&&purchaser.alias && {alias:purchaser.alias} ...purchaser&&purchaser.alias && {alias:purchaser.alias},
role: constants.chat_roles.reader,
}, },
type: constants.message_types.purchase, type: constants.message_types.purchase,
message: msg, message: msg,
amount: amount, amount: amount,
success: ()=>{}, success: ()=>{},
failure: ()=>{} failure: ()=>{},
isForwarded: true,
}) })
} }
} }
@ -131,7 +133,8 @@ export async function sendFinalMemeIfFirstPurchaser(payload, chat, sender){
sendMessage({ sendMessage({
sender: { sender: {
...owner.dataValues, ...owner.dataValues,
...sender&&sender.alias && {alias:sender.alias} ...sender&&sender.alias && {alias:sender.alias},
role: constants.chat_roles.reader,
}, },
chat:{ chat:{
...chat.dataValues, ...chat.dataValues,
@ -144,7 +147,8 @@ export async function sendFinalMemeIfFirstPurchaser(payload, chat, sender){
originalMuid:muid, originalMuid:muid,
}, },
success: ()=>{}, success: ()=>{},
receive: ()=>{} receive: ()=>{},
isForwarded: true,
}) })
} }

3
api/network/receive.ts

@ -193,7 +193,8 @@ async function forwardMessageToTribe(ogpayload, sender){
chat: chat, chat: chat,
skipPubKey: payload.sender.pub_key, skipPubKey: payload.sender.pub_key,
success: ()=>{}, success: ()=>{},
receive: ()=>{} receive: ()=>{},
isForwarded: true,
}) })
} }

19
api/network/send.ts

@ -15,8 +15,17 @@ type NetworkType = undefined | 'mqtt' | 'lightning'
const MIN_SATS = 3; const MIN_SATS = 3;
export async function sendMessage(params) { export async function sendMessage(params) {
const { type, chat, message, sender, amount, success, failure, skipPubKey } = params const { type, chat, message, sender, amount, success, failure, skipPubKey, isForwarded } = params
let msg = newmsg(type, chat, sender, message) if(!chat || !sender) return
const isTribe = chat.type===constants.chat_types.tribe
let isTribeOwner = isTribe && sender.publicKey===chat.ownerPubkey
let theSender = (sender.dataValues||sender)
if(isTribeOwner && !isForwarded) {
theSender = {...(sender.dataValues||sender), role:constants.chat_roles.owner}
}
let msg = newmsg(type, chat, theSender, message)
// console.log("=> MSG TO SEND",msg) // console.log("=> MSG TO SEND",msg)
@ -35,12 +44,8 @@ export async function sendMessage(params) {
} }
let networkType:NetworkType = undefined let networkType:NetworkType = undefined
const isTribe = chat.type===constants.chat_types.tribe
let isTribeOwner = false
const chatUUID = chat.uuid const chatUUID = chat.uuid
if(isTribe) { if(isTribe) {
const tribeOwnerPubKey = chat.ownerPubkey
isTribeOwner = sender.publicKey===tribeOwnerPubKey
if(type===constants.message_types.confirmation) { if(type===constants.message_types.confirmation) {
// if u are owner, go ahead! // if u are owner, go ahead!
if(!isTribeOwner) return // dont send confs for tribe if not owner if(!isTribeOwner) return // dont send confs for tribe if not owner
@ -58,7 +63,7 @@ export async function sendMessage(params) {
tribes.putActivity(chat.uuid, chat.host) tribes.putActivity(chat.uuid, chat.host)
} else { } else {
// if tribe, send to owner only // if tribe, send to owner only
const tribeOwner = await models.Contact.findOne({where: {publicKey:tribeOwnerPubKey}}) const tribeOwner = await models.Contact.findOne({where: {publicKey:chat.ownerPubkey}})
contactIds = tribeOwner ? [tribeOwner.id] : [] contactIds = tribeOwner ? [tribeOwner.id] : []
} }
} }

5
dist/api/controllers/actions.js

@ -168,13 +168,14 @@ function finalAction(a, bot_id) {
}); });
yield network.sendMessage({ yield network.sendMessage({
chat: theChat, chat: theChat,
sender: Object.assign(Object.assign({}, owner.dataValues), { alias, id: botContactId }), sender: Object.assign(Object.assign({}, owner.dataValues), { alias, id: botContactId, role: constants.chat_roles.reader }),
message: { content: textMap, id: message.id, uuid: message.uuid }, message: { content: textMap, id: message.id, uuid: message.uuid },
type: constants.message_types.bot_res, type: constants.message_types.bot_res,
success: () => ({ success: true }), success: () => ({ success: true }),
failure: (e) => { failure: (e) => {
throw e; throw e;
} },
isForwarded: true,
}); });
} }
else { else {

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

File diff suppressed because one or more lines are too long

2
dist/api/controllers/chatTribes.js

@ -416,7 +416,7 @@ function replayChatHistory(chat, contact) {
asyncForEach(msgs, (m) => __awaiter(this, void 0, void 0, function* () { asyncForEach(msgs, (m) => __awaiter(this, void 0, void 0, function* () {
if (!network.typesToReplay.includes(m.type)) if (!network.typesToReplay.includes(m.type))
return; // only for message for now return; // only for message for now
const sender = Object.assign(Object.assign({}, owner.dataValues), m.senderAlias && { alias: m.senderAlias }); const sender = Object.assign(Object.assign(Object.assign({}, owner.dataValues), m.senderAlias && { alias: m.senderAlias }), { role: constants.chat_roles.reader });
let content = ''; let content = '';
try { try {
content = JSON.parse(m.remoteMessageContent); content = JSON.parse(m.remoteMessageContent);

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

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

2
dist/api/network/intercept.js

@ -77,7 +77,7 @@ function isBotMsg(msg, sentByMe) {
exports.isBotMsg = isBotMsg; exports.isBotMsg = isBotMsg;
function emitMessageToBot(msg, botInTribe) { function emitMessageToBot(msg, botInTribe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// console.log('emitMessageToBot',msg) console.log('=> emitMessageToBot', JSON.stringify(msg, null, 2));
switch (botInTribe.botType) { switch (botInTribe.botType) {
case constants.bot_types.builtin: case constants.bot_types.builtin:
builtin_1.builtinBotEmit(msg); builtin_1.builtinBotEmit(msg);

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,wCAA2C;AAC3C,8CAAoE;AACpE,6BAA4B;AAC5B,wCAAuC;AAEvC,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,CAAA;AAE9E;;;EAGE;AAEF,kDAAkD;AAClD,SAAsB,QAAQ,CAAC,GAAQ,EAAE,QAAiB;;QACxD,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAA;QAE9C,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAA;QACxB,IAAI,OAAO,KAAK,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE;YAC/C,OAAO,KAAK,CAAA,CAAC,sCAAsC;SACpD;QACD,MAAM,IAAI,GAAG,MAAM,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC;YACrC,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI;aACpB;SACF,CAAC,CAAA;QACF,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAA;QAEvB,IAAI,OAAO,GAAG,KAAK,CAAA;QAEnB,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;YAClC,wBAAc,CAAC,GAAG,CAAC,CAAA;YACnB,OAAO,GAAG,IAAI,CAAA;SACf;QACD,IAAI,OAAO;YAAE,OAAO,OAAO,CAAA;Q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AC9D,KAAK,SAAS,CAAC,SAAS,CAAC,MAAM;gBAC7B,OAAO,oBAAa,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;YACvC;gBACE,OAAO,KAAK,CAAA;SACf;IACH,CAAC;CAAA;AAED,SAAe,YAAY,CAAC,KAAK,EAAE,QAAQ;;QACzC,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;IACH,CAAC;CAAA"}

10
dist/api/network/modify.js

@ -96,12 +96,13 @@ function purchaseFromOriginalSender(payload, chat, purchaser) {
const msg = { mediaToken: mt, purchaser: purchaser.id }; const msg = { mediaToken: mt, purchaser: purchaser.id };
send_1.sendMessage({ send_1.sendMessage({
chat: Object.assign(Object.assign({}, chat.dataValues), { contactIds: [ogmsg.sender] }), chat: Object.assign(Object.assign({}, chat.dataValues), { contactIds: [ogmsg.sender] }),
sender: Object.assign(Object.assign({}, owner.dataValues), purchaser && purchaser.alias && { alias: purchaser.alias }), sender: Object.assign(Object.assign(Object.assign({}, owner.dataValues), purchaser && purchaser.alias && { alias: purchaser.alias }), { role: constants.chat_roles.reader }),
type: constants.message_types.purchase, type: constants.message_types.purchase,
message: msg, message: msg,
amount: amount, amount: amount,
success: () => { }, success: () => { },
failure: () => { } failure: () => { },
isForwarded: true,
}); });
} }
}); });
@ -138,12 +139,13 @@ function sendFinalMemeIfFirstPurchaser(payload, chat, sender) {
// send it to the purchaser // send it to the purchaser
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
send_1.sendMessage({ send_1.sendMessage({
sender: Object.assign(Object.assign({}, owner.dataValues), sender && sender.alias && { alias: sender.alias }), sender: Object.assign(Object.assign(Object.assign({}, owner.dataValues), sender && sender.alias && { alias: sender.alias }), { role: constants.chat_roles.reader }),
chat: Object.assign(Object.assign({}, chat.dataValues), { contactIds: [ogPurchaser.id] }), chat: Object.assign(Object.assign({}, chat.dataValues), { contactIds: [ogPurchaser.id] }),
type: msgtypes.purchase_accept, type: msgtypes.purchase_accept,
message: Object.assign(Object.assign({}, termsAndKey), { mediaType: typ, originalMuid: muid }), message: Object.assign(Object.assign({}, termsAndKey), { mediaType: typ, originalMuid: muid }),
success: () => { }, success: () => { },
receive: () => { } receive: () => { },
isForwarded: true,
}); });
}); });
} }

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

File diff suppressed because one or more lines are too long

3
dist/api/network/receive.js

@ -209,7 +209,8 @@ function forwardMessageToTribe(ogpayload, sender) {
chat: chat, chat: chat,
skipPubKey: payload.sender.pub_key, skipPubKey: payload.sender.pub_key,
success: () => { }, success: () => { },
receive: () => { } receive: () => { },
isForwarded: true,
}); });
}); });
} }

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

File diff suppressed because one or more lines are too long

18
dist/api/network/send.js

@ -22,8 +22,16 @@ const constants = require(path.join(__dirname, '../../config/constants.json'));
const MIN_SATS = 3; const MIN_SATS = 3;
function sendMessage(params) { function sendMessage(params) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const { type, chat, message, sender, amount, success, failure, skipPubKey } = params; const { type, chat, message, sender, amount, success, failure, skipPubKey, isForwarded } = params;
let msg = newmsg(type, chat, sender, message); if (!chat || !sender)
return;
const isTribe = chat.type === constants.chat_types.tribe;
let isTribeOwner = isTribe && sender.publicKey === chat.ownerPubkey;
let theSender = (sender.dataValues || sender);
if (isTribeOwner && !isForwarded) {
theSender = Object.assign(Object.assign({}, (sender.dataValues || sender)), { role: constants.chat_roles.owner });
}
let msg = newmsg(type, chat, theSender, message);
// console.log("=> MSG TO SEND",msg) // console.log("=> MSG TO SEND",msg)
// console.log(type,message) // console.log(type,message)
if (!(sender && sender.publicKey)) { if (!(sender && sender.publicKey)) {
@ -39,12 +47,8 @@ function sendMessage(params) {
} }
} }
let networkType = undefined; let networkType = undefined;
const isTribe = chat.type === constants.chat_types.tribe;
let isTribeOwner = false;
const chatUUID = chat.uuid; const chatUUID = chat.uuid;
if (isTribe) { if (isTribe) {
const tribeOwnerPubKey = chat.ownerPubkey;
isTribeOwner = sender.publicKey === tribeOwnerPubKey;
if (type === constants.message_types.confirmation) { if (type === constants.message_types.confirmation) {
// if u are owner, go ahead! // if u are owner, go ahead!
if (!isTribeOwner) if (!isTribeOwner)
@ -64,7 +68,7 @@ function sendMessage(params) {
} }
else { else {
// if tribe, send to owner only // if tribe, send to owner only
const tribeOwner = yield models_1.models.Contact.findOne({ where: { publicKey: tribeOwnerPubKey } }); const tribeOwner = yield models_1.models.Contact.findOne({ where: { publicKey: chat.ownerPubkey } });
contactIds = tribeOwner ? [tribeOwner.id] : []; contactIds = tribeOwner ? [tribeOwner.id] : [];
} }
} }

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

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