Browse Source

newmsg sender.role = isTribeOwner

push-params
Evan Feenstra 4 years ago
parent
commit
c340d4712e
  1. 2
      api/controllers/chatTribes.ts
  2. 17
      api/network/send.ts
  3. 2
      dist/api/controllers/chatTribes.js
  4. 2
      dist/api/controllers/chatTribes.js.map
  5. 16
      dist/api/network/send.js
  6. 2
      dist/api/network/send.js.map

2
api/controllers/chatTribes.ts

@ -446,7 +446,7 @@ export async function replayChatHistory(chat, contact) {
...newMediaTerms && {mediaToken: newMediaTerms},
...m.mediaType && {mediaType: m.mediaType},
...dateString && {date: dateString}
})
}, true)
msg = await decryptMessage(msg, chat)
const data = await personalizeMessage(msg, contact, true)
const mqttTopic = `${contact.publicKey}/${chat.uuid}`

17
api/network/send.ts

@ -16,7 +16,12 @@ const MIN_SATS = 3;
export async function sendMessage(params) {
const { type, chat, message, sender, amount, success, failure, skipPubKey } = 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 msg = newmsg(type, chat, sender, message, isTribeOwner)
// console.log("=> MSG TO SEND",msg)
@ -35,12 +40,8 @@ export async function sendMessage(params) {
}
let networkType:NetworkType = undefined
const isTribe = chat.type===constants.chat_types.tribe
let isTribeOwner = false
const chatUUID = chat.uuid
if(isTribe) {
const tribeOwnerPubKey = chat.ownerPubkey
isTribeOwner = sender.publicKey===tribeOwnerPubKey
if(type===constants.message_types.confirmation) {
// if u are owner, go ahead!
if(!isTribeOwner) return // dont send confs for tribe if not owner
@ -58,7 +59,7 @@ export async function sendMessage(params) {
tribes.putActivity(chat.uuid, chat.host)
} else {
// 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] : []
}
}
@ -152,7 +153,7 @@ function checkIfAutoConfirm(data){
}
}
export function newmsg(type, chat, sender, message){
export function newmsg(type, chat, sender, message, isTribeOwner:boolean){
const includeGroupKey = type===constants.message_types.group_create || type===constants.message_types.group_invite
const includeAlias = sender && sender.alias && chat.type===constants.chat_types.tribe
// const includePhotoUrl = sender && sender.photoUrl && !sender.privatePhoto
@ -170,7 +171,7 @@ export function newmsg(type, chat, sender, message){
sender: {
pub_key: sender.publicKey,
alias: includeAlias ? sender.alias : '',
role: sender.role || constants.chat_roles.reader,
role: isTribeOwner ? constants.chat_roles.owner : constants.chat_roles.reader,
// ...includePhotoUrl && {photo_url: sender.photoUrl},
// ...sender.contactKey && {contact_key: sender.contactKey}
}

2
dist/api/controllers/chatTribes.js

@ -438,7 +438,7 @@ function replayChatHistory(chat, contact) {
}
}
}
let msg = network.newmsg(m.type, chat, sender, Object.assign(Object.assign(Object.assign(Object.assign({ content }, mediaKeyMap && { mediaKey: mediaKeyMap }), newMediaTerms && { mediaToken: newMediaTerms }), m.mediaType && { mediaType: m.mediaType }), dateString && { date: dateString }));
let msg = network.newmsg(m.type, chat, sender, Object.assign(Object.assign(Object.assign(Object.assign({ content }, mediaKeyMap && { mediaKey: mediaKeyMap }), newMediaTerms && { mediaToken: newMediaTerms }), m.mediaType && { mediaType: m.mediaType }), dateString && { date: dateString }), true);
msg = yield msg_1.decryptMessage(msg, chat);
const data = yield msg_1.personalizeMessage(msg, contact, true);
const mqttTopic = `${contact.publicKey}/${chat.uuid}`;

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

File diff suppressed because one or more lines are too long

16
dist/api/network/send.js

@ -23,7 +23,11 @@ const MIN_SATS = 3;
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);
if (!chat || !sender)
return;
const isTribe = chat.type === constants.chat_types.tribe;
let isTribeOwner = isTribe && sender.publicKey === chat.ownerPubkey;
let msg = newmsg(type, chat, sender, message, isTribeOwner);
// console.log("=> MSG TO SEND",msg)
// console.log(type,message)
if (!(sender && sender.publicKey)) {
@ -39,12 +43,8 @@ function sendMessage(params) {
}
}
let networkType = undefined;
const isTribe = chat.type === constants.chat_types.tribe;
let isTribeOwner = false;
const chatUUID = chat.uuid;
if (isTribe) {
const tribeOwnerPubKey = chat.ownerPubkey;
isTribeOwner = sender.publicKey === tribeOwnerPubKey;
if (type === constants.message_types.confirmation) {
// if u are owner, go ahead!
if (!isTribeOwner)
@ -64,7 +64,7 @@ function sendMessage(params) {
}
else {
// 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] : [];
}
}
@ -160,7 +160,7 @@ function checkIfAutoConfirm(data) {
confirmations_1.tribeOwnerAutoConfirmation(data.message.id, data.chat.uuid);
}
}
function newmsg(type, chat, sender, message) {
function newmsg(type, chat, sender, message, isTribeOwner) {
const includeGroupKey = type === constants.message_types.group_create || type === constants.message_types.group_invite;
const includeAlias = sender && sender.alias && chat.type === constants.chat_types.tribe;
// const includePhotoUrl = sender && sender.photoUrl && !sender.privatePhoto
@ -171,7 +171,7 @@ function newmsg(type, chat, sender, message) {
sender: {
pub_key: sender.publicKey,
alias: includeAlias ? sender.alias : '',
role: sender.role || constants.chat_roles.reader,
role: isTribeOwner ? constants.chat_roles.owner : constants.chat_roles.reader,
}
};
}

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

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