Browse Source

add reply_uuid

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
53f4f59881
  1. 1
      api/controllers/chatTribes.ts
  2. 19
      api/controllers/messages.ts
  3. 3
      api/helpers.ts
  4. 14
      api/hub.ts
  5. 3
      api/models/ts/message.ts
  6. 1
      dist/api/controllers/chatTribes.js
  7. 2
      dist/api/controllers/chatTribes.js.map
  8. 21
      dist/api/controllers/messages.js
  9. 2
      dist/api/controllers/messages.js.map
  10. 3
      dist/api/helpers.js
  11. 2
      dist/api/helpers.js.map
  12. 11
      dist/api/hub.js
  13. 2
      dist/api/hub.js.map
  14. 4
      dist/api/models/ts/message.js
  15. 2
      dist/api/models/ts/message.js.map

1
api/controllers/chatTribes.ts

@ -166,7 +166,6 @@ async function replayChatHistory(chat, contact) {
let content = ''
try {content = JSON.parse(m.remoteMessageContent)} catch(e) {}
console.log(m.date, typeof m.date, m.date.toISOString())
const dateString = m.date&&m.date.toISOString()
let mediaKeyMap
let newMediaTerms

19
api/controllers/messages.ts

@ -108,6 +108,7 @@ const sendMessage = async (req, res) => {
chat_id,
remote_text_map,
amount,
reply_uuid,
} = req.body
var date = new Date();
@ -121,7 +122,7 @@ const sendMessage = async (req, res) => {
})
const remoteMessageContent = remote_text_map?JSON.stringify(remote_text_map) : remote_text
const msg={
const msg:{[k:string]:any}={
chatId: chat.id,
uuid: short.generate(),
type: constants.message_types.message,
@ -134,21 +135,24 @@ const sendMessage = async (req, res) => {
createdAt: date,
updatedAt: date,
}
if(reply_uuid) msg.replyUuid=reply_uuid
// console.log(msg)
const message = await models.Message.create(msg)
success(res, jsonUtils.messageToJson(message, chat))
const msgToSend:{[k:string]:any} = {
id: message.id,
uuid: message.uuid,
content: remote_text_map || remote_text || text
}
if(reply_uuid) msgToSend.replyUuid=reply_uuid
network.sendMessage({
chat: chat,
sender: owner,
amount: amount||0,
type: constants.message_types.message,
message: {
id: message.id,
uuid: message.uuid,
content: remote_text_map || remote_text || text
}
message: msgToSend,
})
}
@ -159,7 +163,7 @@ const receiveMessage = async (payload) => {
date.setMilliseconds(0)
const total_spent = 1
const {owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias, msg_uuid, date_string} = await helpers.parseReceiveParams(payload)
const {owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias, msg_uuid, date_string, reply_uuid} = await helpers.parseReceiveParams(payload)
if(!owner || !sender || !chat) {
return console.log('=> no group chat!')
}
@ -183,6 +187,7 @@ const receiveMessage = async (payload) => {
msg.senderAlias = sender_alias
if(remote_content) msg.remoteMessageContent=remote_content
}
if(reply_uuid) msg.replyUuid = reply_uuid
const message = await models.Message.create(msg)
// console.log('saved message', message.dataValues)

3
api/helpers.ts

@ -151,6 +151,7 @@ async function parseReceiveParams(payload) {
const mediaKey = dat.message.mediaKey
const mediaType = dat.message.mediaType
const date_string = dat.message.date
const reply_uuid = dat.message.replyUuid
const isTribeOwner = dat.isTribeOwner?true:false
const isConversation = !chat_type || (chat_type && chat_type == constants.chat_types.conversation)
@ -173,7 +174,7 @@ async function parseReceiveParams(payload) {
}
chat = await models.Chat.findOne({ where: { uuid: chat_uuid } })
}
return { owner, sender, chat, sender_pub_key, sender_alias, isTribeOwner, chat_uuid, amount, content, mediaToken, mediaKey, mediaType, originalMuid, chat_type, msg_id, chat_members, chat_name, chat_host, chat_key, remote_content, msg_uuid, date_string }
return { owner, sender, chat, sender_pub_key, sender_alias, isTribeOwner, chat_uuid, amount, content, mediaToken, mediaKey, mediaType, originalMuid, chat_type, msg_id, chat_members, chat_name, chat_host, chat_key, remote_content, msg_uuid, date_string, reply_uuid }
}
export {

14
api/hub.ts

@ -223,6 +223,12 @@ const sendNotification = async (chat, name, type) => {
const unseenMessages = await models.Message.count({ where: { sender: { [Op.ne]: owner.id }, seen: false } })
// if(type==='message' && chat.type==constants.chat_types.tribe){
// debounce(()=>{
// },)
// }
const params = {
device_id: owner.deviceId,
notification: {
@ -253,3 +259,11 @@ export {
payInviteInHub,
payInviteInvoice
}
// let inDebounce
// function debounce(func, delay) {
// const context = this
// const args = arguments
// clearTimeout(inDebounce)
// inDebounce = setTimeout(() => func.apply(context, args), delay)
// }

3
api/models/ts/message.ts

@ -89,4 +89,7 @@ export default class Message extends Model<Message> {
@Column
originalMuid: string // for tribe, remember the og muid
@Column
replyUuid: string
}

1
dist/api/controllers/chatTribes.js

@ -164,7 +164,6 @@ function replayChatHistory(chat, contact) {
content = JSON.parse(m.remoteMessageContent);
}
catch (e) { }
console.log(m.date, typeof m.date, m.date.toISOString());
const dateString = m.date && m.date.toISOString();
let mediaKeyMap;
let newMediaTerms;

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

File diff suppressed because one or more lines are too long

21
dist/api/controllers/messages.js

@ -98,7 +98,7 @@ const sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
// } catch(e) {
// return failure(res, e.message)
// }
const { contact_id, text, remote_text, chat_id, remote_text_map, amount, } = req.body;
const { contact_id, text, remote_text, chat_id, remote_text_map, amount, reply_uuid, } = req.body;
var date = new Date();
date.setMilliseconds(0);
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
@ -121,19 +121,24 @@ const sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
createdAt: date,
updatedAt: date,
};
if (reply_uuid)
msg.replyUuid = reply_uuid;
// console.log(msg)
const message = yield models_1.models.Message.create(msg);
res_1.success(res, jsonUtils.messageToJson(message, chat));
const msgToSend = {
id: message.id,
uuid: message.uuid,
content: remote_text_map || remote_text || text
};
if (reply_uuid)
msgToSend.replyUuid = reply_uuid;
network.sendMessage({
chat: chat,
sender: owner,
amount: amount || 0,
type: constants.message_types.message,
message: {
id: message.id,
uuid: message.uuid,
content: remote_text_map || remote_text || text
}
message: msgToSend,
});
});
exports.sendMessage = sendMessage;
@ -142,7 +147,7 @@ const receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function*
var date = new Date();
date.setMilliseconds(0);
const total_spent = 1;
const { owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias, msg_uuid, date_string } = yield helpers.parseReceiveParams(payload);
const { owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias, msg_uuid, date_string, reply_uuid } = yield helpers.parseReceiveParams(payload);
if (!owner || !sender || !chat) {
return console.log('=> no group chat!');
}
@ -166,6 +171,8 @@ const receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function*
if (remote_content)
msg.remoteMessageContent = remote_content;
}
if (reply_uuid)
msg.replyUuid = reply_uuid;
const message = yield models_1.models.Message.create(msg);
// console.log('saved message', message.dataValues)
socket.sendJson({

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

File diff suppressed because one or more lines are too long

3
dist/api/helpers.js

@ -167,6 +167,7 @@ function parseReceiveParams(payload) {
const mediaKey = dat.message.mediaKey;
const mediaType = dat.message.mediaType;
const date_string = dat.message.date;
const reply_uuid = dat.message.replyUuid;
const isTribeOwner = dat.isTribeOwner ? true : false;
const isConversation = !chat_type || (chat_type && chat_type == constants.chat_types.conversation);
let sender;
@ -187,7 +188,7 @@ function parseReceiveParams(payload) {
}
chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } });
}
return { owner, sender, chat, sender_pub_key, sender_alias, isTribeOwner, chat_uuid, amount, content, mediaToken, mediaKey, mediaType, originalMuid, chat_type, msg_id, chat_members, chat_name, chat_host, chat_key, remote_content, msg_uuid, date_string };
return { owner, sender, chat, sender_pub_key, sender_alias, isTribeOwner, chat_uuid, amount, content, mediaToken, mediaKey, mediaType, originalMuid, chat_type, msg_id, chat_members, chat_name, chat_host, chat_key, remote_content, msg_uuid, date_string, reply_uuid };
});
}
exports.parseReceiveParams = parseReceiveParams;

2
dist/api/helpers.js.map

File diff suppressed because one or more lines are too long

11
dist/api/hub.js

@ -214,6 +214,10 @@ const sendNotification = (chat, name, type) => __awaiter(void 0, void 0, void 0,
return;
}
const unseenMessages = yield models_1.models.Message.count({ where: { sender: { [sequelize_1.Op.ne]: owner.id }, seen: false } });
// if(type==='message' && chat.type==constants.chat_types.tribe){
// debounce(()=>{
// },)
// }
const params = {
device_id: owner.deviceId,
notification: {
@ -233,4 +237,11 @@ const sendNotification = (chat, name, type) => __awaiter(void 0, void 0, void 0,
});
});
exports.sendNotification = sendNotification;
// let inDebounce
// function debounce(func, delay) {
// const context = this
// const args = arguments
// clearTimeout(inDebounce)
// inDebounce = setTimeout(() => func.apply(context, args), delay)
// }
//# sourceMappingURL=hub.js.map

2
dist/api/hub.js.map

File diff suppressed because one or more lines are too long

4
dist/api/models/ts/message.js

@ -125,6 +125,10 @@ __decorate([
sequelize_typescript_1.Column,
__metadata("design:type", String)
], Message.prototype, "originalMuid", void 0);
__decorate([
sequelize_typescript_1.Column,
__metadata("design:type", String)
], Message.prototype, "replyUuid", void 0);
Message = __decorate([
sequelize_typescript_1.Table({ tableName: 'sphinx_messages', underscored: true })
], Message);

2
dist/api/models/ts/message.js.map

@ -1 +1 @@
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../api/models/ts/message.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAsE;AAGtE,IAAqB,OAAO,GAA5B,MAAqB,OAAQ,SAAQ,4BAAc;CAwFlD,CAAA;AAhFC;IANC,6BAAM,CAAC;QACN,IAAI,EAAE,+BAAQ,CAAC,MAAM;QACrB,UAAU,EAAE,IAAI;QAChB,MAAM,EAAE,IAAI;QACZ,aAAa,EAAE,IAAI;KACpB,CAAC;;mCACQ;AAGV;IADC,6BAAM;;qCACK;AAGZ;IADC,6BAAM,CAAC,+BAAQ,CAAC,MAAM,CAAC;;uCACV;AAGd;IADC,6BAAM,CAAC,+BAAQ,CAAC,MAAM,CAAC;;qCACZ;AAGZ;IADC,6BAAM,CAAC,+BAAQ,CAAC,MAAM,CAAC;;uCACV;AAGd;IADC,6BAAM,CAAC,+BAAQ,CAAC,MAAM,CAAC;;yCACR;AAGhB;IADC,6BAAM,CAAC,+BAAQ,CAAC,OAAO,CAAC;;uCACX;AAGd;IADC,6BAAM,CAAC,+BAAQ,CAAC,OAAO,CAAC;;2CACP;AAGlB;IADC,6BAAM;;4CACY;AAGnB;IADC,6BAAM,CAAC,+BAAQ,CAAC,IAAI,CAAC;;+CACA;AAGtB;IADC,6BAAM;8BACD,IAAI;qCAAA;AAGV;IADC,6BAAM;8BACS,IAAI;+CAAA;AAGpB;IADC,6BAAM,CAAC,+BAAQ,CAAC,IAAI,CAAC;;+CACA;AAGtB;IADC,6BAAM,CAAC,+BAAQ,CAAC,IAAI,CAAC;;qDACM;AAG5B;IADC,6BAAM,CAAC,+BAAQ,CAAC,MAAM,CAAC;;uCACV;AAGd;IADC,6BAAM,CAAC,+BAAQ,CAAC,IAAI,CAAC;;0CACL;AAGjB;IADC,6BAAM,CAAC,+BAAQ,CAAC,MAAM,CAAC;;yCACR;AAGhB;IADC,6BAAM,CAAC,+BAAQ,CAAC,MAAM,CAAC;;+CACF;AAGtB;IADC,6BAAM;;yCACS;AAGhB;IADC,6BAAM;;0CACU;AAGjB;IADC,6BAAM;;2CACW;AAOlB;IALC,6BAAM,CAAC;QACN,IAAI,EAAE,+BAAQ,CAAC,OAAO;QACtB,YAAY,EAAE,KAAK;QACnB,SAAS,EAAE,KAAK;KACjB,CAAC;;qCACW;AAGb;IADC,6BAAM;8BACI,IAAI;0CAAA;AAGf;IADC,6BAAM;8BACI,IAAI;0CAAA;AAGf;IADC,6BAAM;;4CACY;AAGnB;IADC,6BAAM;;6CACa;AAvFD,OAAO;IAD3B,4BAAK,CAAC,EAAC,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,IAAI,EAAC,CAAC;GACpC,OAAO,CAwF3B;kBAxFoB,OAAO"}
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../api/models/ts/message.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAsE;AAGtE,IAAqB,OAAO,GAA5B,MAAqB,OAAQ,SAAQ,4BAAc;CA2FlD,CAAA;AAnFC;IANC,6BAAM,CAAC;QACN,IAAI,EAAE,+BAAQ,CAAC,MAAM;QACrB,UAAU,EAAE,IAAI;QAChB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