Browse Source

lock private tribe in network.receive

push-params
Evan Feenstra 5 years ago
parent
commit
0b4dc32370
  1. 2
      api/controllers/chatTribes.ts
  2. 10
      api/network/receive.ts
  3. 2
      api/network/send.ts
  4. 2
      dist/api/controllers/chatTribes.js
  5. 2
      dist/api/controllers/chatTribes.js.map
  6. 8
      dist/api/network/receive.js
  7. 2
      dist/api/network/receive.js.map
  8. 1
      dist/api/network/send.js
  9. 2
      dist/api/network/send.js.map

2
api/controllers/chatTribes.ts

@ -309,7 +309,7 @@ export async function receiveMemberApprove(payload) {
})
const theChat = chat.dataValues||chat
// send my info to all
// send JOIN and my info to all
network.sendMessage({
chat: { ...theChat,
members: {

10
api/network/receive.ts

@ -34,7 +34,7 @@ export const typesToReplay=[ // should match typesToForward
msgtypes.message, msgtypes.group_join, msgtypes.group_leave
]
async function onReceive(payload){
// console.log("ON RECEIVE",payload)
console.log("=> ON RECEIVE",payload)
// if tribe, owner must forward to MQTT
let doAction = true
const toAddIn:{[k:string]:any} = {}
@ -73,9 +73,15 @@ async function onReceive(payload){
})
}
}
// check price to join
// check price to join AND private chat
if(payload.type===msgtypes.group_join) {
if(payload.message.amount<chat.priceToJoin) doAction=false
if(chat.private) { // check if has been approved
const senderMember = senderContact && await models.ChatMember.findOne({where:{contactId:senderContact.id, chatId:chat.id}})
if(!(senderMember && senderMember.status===constants.chat_statuses.approved)){
doAction=false // dont let if private and not approved
}
}
}
// check that the sender is the og poster
if(payload.type===msgtypes.delete) {

2
api/network/send.ts

@ -15,6 +15,8 @@ export async function sendMessage(params) {
const { type, chat, message, sender, amount, success, failure, skipPubKey } = params
let msg = newmsg(type, chat, sender, message)
console.log("=> MSG TO SEND",msg)
// console.log(type,message)
if(!(sender&&sender.publicKey)) {
console.log("NO SENDER?????")

2
dist/api/controllers/chatTribes.js

@ -298,7 +298,7 @@ function receiveMemberApprove(payload) {
}
});
const theChat = chat.dataValues || chat;
// send my info to all
// send JOIN and my info to all
network.sendMessage({
chat: Object.assign(Object.assign({}, theChat), { members: {
[owner.publicKey]: {

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

File diff suppressed because one or more lines are too long

8
dist/api/network/receive.js

@ -86,10 +86,16 @@ function onReceive(payload) {
});
}
}
// check price to join
// check price to join AND private chat
if (payload.type === msgtypes.group_join) {
if (payload.message.amount < chat.priceToJoin)
doAction = false;
if (chat.private) { // check if has been approved
const senderMember = senderContact && (yield models_1.models.ChatMember.findOne({ where: { contactId: senderContact.id, chatId: chat.id } }));
if (!(senderMember && senderMember.status === constants.chat_statuses.approved)) {
doAction = false; // dont let if private and not approved
}
}
}
// check that the sender is the og poster
if (payload.type === msgtypes.delete) {

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

File diff suppressed because one or more lines are too long

1
dist/api/network/send.js

@ -22,6 +22,7 @@ function sendMessage(params) {
return __awaiter(this, void 0, void 0, function* () {
const { type, chat, message, sender, amount, success, failure, skipPubKey } = params;
let msg = newmsg(type, chat, sender, message);
console.log("=> MSG TO SEND", msg);
// console.log(type,message)
if (!(sender && sender.publicKey)) {
console.log("NO SENDER?????");

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

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