Browse Source

parse date string on receive bot res

push-params
Evan Feenstra 5 years ago
parent
commit
b14a61982e
  1. 3
      dist/src/controllers/bots.js
  2. 2
      dist/src/controllers/bots.js.map
  3. 4
      dist/src/controllers/chatTribes.js
  4. 2
      dist/src/controllers/chatTribes.js.map
  5. 4
      dist/src/controllers/messages.js
  6. 2
      dist/src/controllers/messages.js.map
  7. 4
      src/controllers/bots.ts
  8. 4
      src/controllers/chatTribes.ts
  9. 5
      src/controllers/messages.ts

3
dist/src/controllers/bots.js

@ -309,6 +309,7 @@ function receiveBotRes(payload) {
const action = dat.action; const action = dat.action;
const bot_name = dat.bot_name; const bot_name = dat.bot_name;
const sender_alias = dat.sender.alias; const sender_alias = dat.sender.alias;
const date_string = dat.message.date;
if (!chat_uuid) if (!chat_uuid)
return console.log('=> receiveBotRes Error no chat_uuid'); return console.log('=> receiveBotRes Error no chat_uuid');
const chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } }); const chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } });
@ -334,6 +335,8 @@ function receiveBotRes(payload) {
return console.log('=> receiveBotRes as sub error no chat'); return console.log('=> receiveBotRes as sub error no chat');
var date = new Date(); var date = new Date();
date.setMilliseconds(0); date.setMilliseconds(0);
if (date_string)
date = new Date(date_string);
const sender = yield models_1.models.Contact.findOne({ where: { publicKey: sender_pub_key } }); const sender = yield models_1.models.Contact.findOne({ where: { publicKey: sender_pub_key } });
const msg = { const msg = {
chatId: chat.id, chatId: chat.id,

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

File diff suppressed because one or more lines are too long

4
dist/src/controllers/chatTribes.js

@ -435,8 +435,6 @@ function replayChatHistory(chat, contact) {
content = JSON.parse(m.remoteMessageContent); content = JSON.parse(m.remoteMessageContent);
} }
catch (e) { } catch (e) { }
console.log("HISTORY DATE", m.date, typeof m.date);
console.log("HISTORY DATE STRING", m.date.toISOString());
const dateString = m.date && m.date.toISOString(); const dateString = m.date && m.date.toISOString();
let mediaKeyMap; let mediaKeyMap;
let newMediaTerms; let newMediaTerms;
@ -458,7 +456,7 @@ function replayChatHistory(chat, contact) {
const data = yield msg_1.personalizeMessage(msg, contact, true); const data = yield msg_1.personalizeMessage(msg, contact, true);
const mqttTopic = `${contact.publicKey}/${chat.uuid}`; const mqttTopic = `${contact.publicKey}/${chat.uuid}`;
const replayingHistory = true; const replayingHistory = true;
console.log("HISTORY DATA:", data); // console.log("-> HISTORY DATA:",data)
yield network.signAndSend({ yield network.signAndSend({
data, data,
dest: contact.publicKey, dest: contact.publicKey,

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

File diff suppressed because one or more lines are too long

4
dist/src/controllers/messages.js

@ -185,14 +185,14 @@ exports.sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function*
}); });
exports.receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function* () { exports.receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function* () {
// console.log('received message', { payload }) // console.log('received message', { payload })
var date = new Date();
date.setMilliseconds(0);
const total_spent = 1; const total_spent = 1;
const { owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias, msg_uuid, date_string, reply_uuid } = 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) { if (!owner || !sender || !chat) {
return console.log('=> no group chat!'); return console.log('=> no group chat!');
} }
const text = content; const text = content;
var date = new Date();
date.setMilliseconds(0);
if (date_string) if (date_string)
date = new Date(date_string); date = new Date(date_string);
const msg = { const msg = {

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

File diff suppressed because one or more lines are too long

4
src/controllers/bots.ts

@ -299,6 +299,8 @@ export async function receiveBotRes(payload) {
const action = dat.action const action = dat.action
const bot_name = dat.bot_name const bot_name = dat.bot_name
const sender_alias = dat.sender.alias const sender_alias = dat.sender.alias
const date_string = dat.message.date
if(!chat_uuid) return console.log('=> receiveBotRes Error no chat_uuid') if(!chat_uuid) return console.log('=> receiveBotRes Error no chat_uuid')
const chat = await models.Chat.findOne({where:{uuid:chat_uuid}}) const chat = await models.Chat.findOne({where:{uuid:chat_uuid}})
@ -324,6 +326,8 @@ export async function receiveBotRes(payload) {
if(!chat) return console.log('=> receiveBotRes as sub error no chat') if(!chat) return console.log('=> receiveBotRes as sub error no chat')
var date = new Date(); var date = new Date();
date.setMilliseconds(0) date.setMilliseconds(0)
if(date_string) date=new Date(date_string)
const sender = await models.Contact.findOne({ where: { publicKey: sender_pub_key } }) const sender = await models.Contact.findOne({ where: { publicKey: sender_pub_key } })
const msg: { [k: string]: any } = { const msg: { [k: string]: any } = {
chatId: chat.id, chatId: chat.id,

4
src/controllers/chatTribes.ts

@ -437,8 +437,6 @@ export async function replayChatHistory(chat, contact) {
let content = '' let content = ''
try {content = JSON.parse(m.remoteMessageContent)} catch(e) {} try {content = JSON.parse(m.remoteMessageContent)} catch(e) {}
console.log("HISTORY DATE",m.date,typeof m.date)
console.log("HISTORY DATE STRING",m.date.toISOString())
const dateString = m.date&&m.date.toISOString() const dateString = m.date&&m.date.toISOString()
let mediaKeyMap let mediaKeyMap
let newMediaTerms let newMediaTerms
@ -466,7 +464,7 @@ export async function replayChatHistory(chat, contact) {
const data = await personalizeMessage(msg, contact, true) const data = await personalizeMessage(msg, contact, true)
const mqttTopic = `${contact.publicKey}/${chat.uuid}` const mqttTopic = `${contact.publicKey}/${chat.uuid}`
const replayingHistory = true const replayingHistory = true
console.log("HISTORY DATA:",data) // console.log("-> HISTORY DATA:",data)
await network.signAndSend({ await network.signAndSend({
data, data,
dest: contact.publicKey, dest: contact.publicKey,

5
src/controllers/messages.ts

@ -209,9 +209,6 @@ export const sendMessage = async (req, res) => {
export const receiveMessage = async (payload) => { export const receiveMessage = async (payload) => {
// console.log('received message', { payload }) // console.log('received message', { payload })
var date = new Date();
date.setMilliseconds(0)
const total_spent = 1 const total_spent = 1
const {owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias, msg_uuid, date_string, reply_uuid} = 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) { if(!owner || !sender || !chat) {
@ -219,6 +216,8 @@ export const receiveMessage = async (payload) => {
} }
const text = content const text = content
var date = new Date();
date.setMilliseconds(0)
if(date_string) date=new Date(date_string) if(date_string) date=new Date(date_string)
const msg:{[k:string]:any} = { const msg:{[k:string]:any} = {

Loading…
Cancel
Save