Browse Source

parse date string on receive bot res

push-params
Evan Feenstra 4 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 bot_name = dat.bot_name;
const sender_alias = dat.sender.alias;
const date_string = dat.message.date;
if (!chat_uuid)
return console.log('=> receiveBotRes Error no 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');
var date = new Date();
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 msg = {
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);
}
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();
let mediaKeyMap;
let newMediaTerms;
@ -458,7 +456,7 @@ function replayChatHistory(chat, contact) {
const data = yield msg_1.personalizeMessage(msg, contact, true);
const mqttTopic = `${contact.publicKey}/${chat.uuid}`;
const replayingHistory = true;
console.log("HISTORY DATA:", data);
// console.log("-> HISTORY DATA:",data)
yield network.signAndSend({
data,
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* () {
// console.log('received message', { payload })
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, reply_uuid } = yield helpers.parseReceiveParams(payload);
if (!owner || !sender || !chat) {
return console.log('=> no group chat!');
}
const text = content;
var date = new Date();
date.setMilliseconds(0);
if (date_string)
date = new Date(date_string);
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 bot_name = dat.bot_name
const sender_alias = dat.sender.alias
const date_string = dat.message.date
if(!chat_uuid) return console.log('=> receiveBotRes Error no 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')
var date = new Date();
date.setMilliseconds(0)
if(date_string) date=new Date(date_string)
const sender = await models.Contact.findOne({ where: { publicKey: sender_pub_key } })
const msg: { [k: string]: any } = {
chatId: chat.id,

4
src/controllers/chatTribes.ts

@ -437,8 +437,6 @@ export async function replayChatHistory(chat, contact) {
let content = ''
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()
let mediaKeyMap
let newMediaTerms
@ -466,7 +464,7 @@ export async function replayChatHistory(chat, contact) {
const data = await personalizeMessage(msg, contact, true)
const mqttTopic = `${contact.publicKey}/${chat.uuid}`
const replayingHistory = true
console.log("HISTORY DATA:",data)
// console.log("-> HISTORY DATA:",data)
await network.signAndSend({
data,
dest: contact.publicKey,

5
src/controllers/messages.ts

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

Loading…
Cancel
Save