Browse Source

Date_string

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
bdabbf3a1b
  1. 2
      api/controllers/chatTribes.ts
  2. 6
      api/controllers/chats.ts
  3. 4
      api/controllers/messages.ts
  4. 3
      api/helpers.ts
  5. 2
      dist/api/controllers/chatTribes.js
  6. 8
      dist/api/controllers/chats.js
  7. 2
      dist/api/controllers/chats.js.map
  8. 4
      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

2
api/controllers/chatTribes.ts

@ -166,7 +166,7 @@ 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(m.date, typeof m.date, m.data.toISOString()) console.log(m.date, typeof m.date, 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

6
api/controllers/chats.ts

@ -198,7 +198,7 @@ const deleteChat = async (req, res) => {
async function receiveGroupJoin(payload) { async function receiveGroupJoin(payload) {
console.log('=> receiveGroupJoin') console.log('=> receiveGroupJoin')
const { sender_pub_key, sender_alias, chat_uuid, chat_members, chat_type, isTribeOwner } = await helpers.parseReceiveParams(payload) const { sender_pub_key, sender_alias, chat_uuid, chat_members, chat_type, isTribeOwner, date_string } = await helpers.parseReceiveParams(payload)
const chat = await models.Chat.findOne({ where: { uuid: chat_uuid } }) const chat = await models.Chat.findOne({ where: { uuid: chat_uuid } })
if (!chat) return if (!chat) return
@ -207,6 +207,7 @@ async function receiveGroupJoin(payload) {
var date = new Date() var date = new Date()
date.setMilliseconds(0) date.setMilliseconds(0)
if(date_string) date=new Date(date_string)
let theSender: any = null let theSender: any = null
const member = chat_members[sender_pub_key] const member = chat_members[sender_pub_key]
@ -285,7 +286,7 @@ async function receiveGroupJoin(payload) {
async function receiveGroupLeave(payload) { async function receiveGroupLeave(payload) {
console.log('=> receiveGroupLeave') console.log('=> receiveGroupLeave')
const { sender_pub_key, chat_uuid, chat_type, sender_alias, isTribeOwner } = await helpers.parseReceiveParams(payload) const { sender_pub_key, chat_uuid, chat_type, sender_alias, isTribeOwner, date_string } = await helpers.parseReceiveParams(payload)
const chat = await models.Chat.findOne({ where: { uuid: chat_uuid } }) const chat = await models.Chat.findOne({ where: { uuid: chat_uuid } })
if (!chat) return if (!chat) return
@ -317,6 +318,7 @@ async function receiveGroupLeave(payload) {
var date = new Date(); var date = new Date();
date.setMilliseconds(0) date.setMilliseconds(0)
if(date_string) date=new Date(date_string)
const msg:{[k:string]:any} = { const msg:{[k:string]:any} = {
chatId: chat.id, chatId: chat.id,
type: constants.message_types.group_leave, type: constants.message_types.group_leave,

4
api/controllers/messages.ts

@ -159,12 +159,14 @@ const receiveMessage = async (payload) => {
date.setMilliseconds(0) 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} = await helpers.parseReceiveParams(payload) const {owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias, msg_uuid, date_string} = await 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
if(date_string) date=new Date(date_string)
const msg:{[k:string]:any} = { const msg:{[k:string]:any} = {
chatId: chat.id, chatId: chat.id,
uuid: msg_uuid, uuid: msg_uuid,

3
api/helpers.ts

@ -150,6 +150,7 @@ async function parseReceiveParams(payload) {
const msg_uuid = dat.message.uuid||'' const msg_uuid = dat.message.uuid||''
const mediaKey = dat.message.mediaKey const mediaKey = dat.message.mediaKey
const mediaType = dat.message.mediaType const mediaType = dat.message.mediaType
const date_string = dat.message.date
const isTribeOwner = dat.isTribeOwner?true:false const isTribeOwner = dat.isTribeOwner?true:false
const isConversation = !chat_type || (chat_type && chat_type == constants.chat_types.conversation) const isConversation = !chat_type || (chat_type && chat_type == constants.chat_types.conversation)
@ -172,7 +173,7 @@ async function parseReceiveParams(payload) {
} }
chat = await models.Chat.findOne({ where: { uuid: chat_uuid } }) 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 } 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 }
} }
export { export {

2
dist/api/controllers/chatTribes.js

@ -164,7 +164,7 @@ function replayChatHistory(chat, contact) {
content = JSON.parse(m.remoteMessageContent); content = JSON.parse(m.remoteMessageContent);
} }
catch (e) { } catch (e) { }
console.log(m.date, typeof m.date, m.data.toISOString()); console.log(m.date, typeof m.date, 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;

8
dist/api/controllers/chats.js

@ -192,13 +192,15 @@ exports.deleteChat = deleteChat;
function receiveGroupJoin(payload) { function receiveGroupJoin(payload) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
console.log('=> receiveGroupJoin'); console.log('=> receiveGroupJoin');
const { sender_pub_key, sender_alias, chat_uuid, chat_members, chat_type, isTribeOwner } = yield helpers.parseReceiveParams(payload); const { sender_pub_key, sender_alias, chat_uuid, chat_members, chat_type, isTribeOwner, date_string } = yield helpers.parseReceiveParams(payload);
const chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } }); const chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } });
if (!chat) if (!chat)
return; return;
const isTribe = chat_type === constants.chat_types.tribe; const isTribe = chat_type === constants.chat_types.tribe;
var date = new Date(); var date = new Date();
date.setMilliseconds(0); date.setMilliseconds(0);
if (date_string)
date = new Date(date_string);
let theSender = null; let theSender = null;
const member = chat_members[sender_pub_key]; const member = chat_members[sender_pub_key];
const senderAlias = sender_alias || (member && member.alias) || 'Unknown'; const senderAlias = sender_alias || (member && member.alias) || 'Unknown';
@ -276,7 +278,7 @@ exports.receiveGroupJoin = receiveGroupJoin;
function receiveGroupLeave(payload) { function receiveGroupLeave(payload) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
console.log('=> receiveGroupLeave'); console.log('=> receiveGroupLeave');
const { sender_pub_key, chat_uuid, chat_type, sender_alias, isTribeOwner } = yield helpers.parseReceiveParams(payload); const { sender_pub_key, chat_uuid, chat_type, sender_alias, isTribeOwner, date_string } = yield helpers.parseReceiveParams(payload);
const chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } }); const chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } });
if (!chat) if (!chat)
return; return;
@ -305,6 +307,8 @@ function receiveGroupLeave(payload) {
} }
var date = new Date(); var date = new Date();
date.setMilliseconds(0); date.setMilliseconds(0);
if (date_string)
date = new Date(date_string);
const msg = { const msg = {
chatId: chat.id, chatId: chat.id,
type: constants.message_types.group_leave, type: constants.message_types.group_leave,

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

File diff suppressed because one or more lines are too long

4
dist/api/controllers/messages.js

@ -142,11 +142,13 @@ const receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function*
var date = new Date(); var date = new Date();
date.setMilliseconds(0); 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 } = yield helpers.parseReceiveParams(payload); const { owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias, msg_uuid, date_string } = 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;
if (date_string)
date = new Date(date_string);
const msg = { const msg = {
chatId: chat.id, chatId: chat.id,
uuid: msg_uuid, uuid: msg_uuid,

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

File diff suppressed because one or more lines are too long

3
dist/api/helpers.js

@ -166,6 +166,7 @@ function parseReceiveParams(payload) {
const msg_uuid = dat.message.uuid || ''; const msg_uuid = dat.message.uuid || '';
const mediaKey = dat.message.mediaKey; const mediaKey = dat.message.mediaKey;
const mediaType = dat.message.mediaType; const mediaType = dat.message.mediaType;
const date_string = dat.message.date;
const isTribeOwner = dat.isTribeOwner ? true : false; const isTribeOwner = dat.isTribeOwner ? true : false;
const isConversation = !chat_type || (chat_type && chat_type == constants.chat_types.conversation); const isConversation = !chat_type || (chat_type && chat_type == constants.chat_types.conversation);
let sender; let sender;
@ -186,7 +187,7 @@ function parseReceiveParams(payload) {
} }
chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } }); 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 }; 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 };
}); });
} }
exports.parseReceiveParams = parseReceiveParams; exports.parseReceiveParams = parseReceiveParams;

2
dist/api/helpers.js.map

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