|
@@ -93,7 +93,8 @@ const removeMessage = async (req, res, next) => {
|
|
|
|
|
|
const sentMessage = async (req, res, next) => {
|
|
const sentMessage = async (req, res, next) => {
|
|
try {
|
|
try {
|
|
- const { id, message } = req.body;
|
|
|
|
|
|
+ const { id, message, caption } = req.body;
|
|
|
|
+ console.log(caption);
|
|
const idTime = Math.round(Date.now() / 1000);
|
|
const idTime = Math.round(Date.now() / 1000);
|
|
const user = req.user;
|
|
const user = req.user;
|
|
const userId = user.id;
|
|
const userId = user.id;
|
|
@@ -111,6 +112,7 @@ const sentMessage = async (req, res, next) => {
|
|
color,
|
|
color,
|
|
number,
|
|
number,
|
|
type: 'text',
|
|
type: 'text',
|
|
|
|
+ caption,
|
|
idTime,
|
|
idTime,
|
|
companionIdFlow: userId,
|
|
companionIdFlow: userId,
|
|
companionId: id,
|
|
companionId: id,
|
|
@@ -124,6 +126,7 @@ const sentMessage = async (req, res, next) => {
|
|
color,
|
|
color,
|
|
number,
|
|
number,
|
|
type: 'text',
|
|
type: 'text',
|
|
|
|
+ caption,
|
|
idTime,
|
|
idTime,
|
|
companionIdFlow: userId,
|
|
companionIdFlow: userId,
|
|
companionId: userId,
|
|
companionId: userId,
|
|
@@ -163,7 +166,8 @@ const sentMessage = async (req, res, next) => {
|
|
const imageMessage = async (req, res, next) => {
|
|
const imageMessage = async (req, res, next) => {
|
|
try {
|
|
try {
|
|
const userId = req.user.id;
|
|
const userId = req.user.id;
|
|
- const id = req.params.companionId;
|
|
|
|
|
|
+ const [id, ...rest] = req.params.companionIdAndCaption.split(' ');
|
|
|
|
+ const caption = rest.join(' ').slice(0, -1);
|
|
const idTime = Math.round(Date.now() / 1000);
|
|
const idTime = Math.round(Date.now() / 1000);
|
|
const isChat = await ChatModel.getByField(id, userId);
|
|
const isChat = await ChatModel.getByField(id, userId);
|
|
const isCompanionChat = await ChatModel.getByField(userId, id);
|
|
const isCompanionChat = await ChatModel.getByField(userId, id);
|
|
@@ -192,6 +196,7 @@ const imageMessage = async (req, res, next) => {
|
|
number,
|
|
number,
|
|
type: 'image',
|
|
type: 'image',
|
|
fullType,
|
|
fullType,
|
|
|
|
+ caption,
|
|
idTime,
|
|
idTime,
|
|
companionIdFlow: userId,
|
|
companionIdFlow: userId,
|
|
companionId: id,
|
|
companionId: id,
|
|
@@ -206,6 +211,7 @@ const imageMessage = async (req, res, next) => {
|
|
number,
|
|
number,
|
|
type: 'image',
|
|
type: 'image',
|
|
fullType,
|
|
fullType,
|
|
|
|
+ caption,
|
|
idTime,
|
|
idTime,
|
|
companionIdFlow: userId,
|
|
companionIdFlow: userId,
|
|
companionId: userId,
|
|
companionId: userId,
|
|
@@ -245,7 +251,9 @@ const imageMessage = async (req, res, next) => {
|
|
const audioMessage = async (req, res, next) => {
|
|
const audioMessage = async (req, res, next) => {
|
|
try {
|
|
try {
|
|
const userId = req.user.id;
|
|
const userId = req.user.id;
|
|
- const id = req.params.companionId;
|
|
|
|
|
|
+ const [id, ...rest] = req.params.companionIdAndCaption.split(' ');
|
|
|
|
+ let caption = rest.join(' ');
|
|
|
|
+ if (caption.length === 1) caption.slice(0, -1);
|
|
const idTime = Math.round(Date.now() / 1000);
|
|
const idTime = Math.round(Date.now() / 1000);
|
|
const isChat = await ChatModel.getByField(id, userId);
|
|
const isChat = await ChatModel.getByField(id, userId);
|
|
const isCompanionChat = await ChatModel.getByField(userId, id);
|
|
const isCompanionChat = await ChatModel.getByField(userId, id);
|
|
@@ -274,6 +282,7 @@ const audioMessage = async (req, res, next) => {
|
|
number,
|
|
number,
|
|
type: 'audio',
|
|
type: 'audio',
|
|
fullType,
|
|
fullType,
|
|
|
|
+ caption,
|
|
idTime,
|
|
idTime,
|
|
companionIdFlow: userId,
|
|
companionIdFlow: userId,
|
|
companionId: id,
|
|
companionId: id,
|
|
@@ -288,6 +297,7 @@ const audioMessage = async (req, res, next) => {
|
|
number,
|
|
number,
|
|
type: 'audio',
|
|
type: 'audio',
|
|
fullType,
|
|
fullType,
|
|
|
|
+ caption,
|
|
idTime,
|
|
idTime,
|
|
companionIdFlow: userId,
|
|
companionIdFlow: userId,
|
|
companionId: userId,
|
|
companionId: userId,
|
|
@@ -327,7 +337,9 @@ const audioMessage = async (req, res, next) => {
|
|
const videoMessage = async (req, res, next) => {
|
|
const videoMessage = async (req, res, next) => {
|
|
try {
|
|
try {
|
|
const userId = req.user.id;
|
|
const userId = req.user.id;
|
|
- const id = req.params.companionId;
|
|
|
|
|
|
+ const [id, ...rest] = req.params.companionIdAndCaption.split(' ');
|
|
|
|
+ let caption = rest.join(' ');
|
|
|
|
+ if (caption.length === 1) caption.slice(0, -1);
|
|
const idTime = Math.round(Date.now() / 1000);
|
|
const idTime = Math.round(Date.now() / 1000);
|
|
const isChat = await ChatModel.getByField(id, userId);
|
|
const isChat = await ChatModel.getByField(id, userId);
|
|
const isCompanionChat = await ChatModel.getByField(userId, id);
|
|
const isCompanionChat = await ChatModel.getByField(userId, id);
|
|
@@ -356,6 +368,7 @@ const videoMessage = async (req, res, next) => {
|
|
number,
|
|
number,
|
|
type: 'video',
|
|
type: 'video',
|
|
fullType,
|
|
fullType,
|
|
|
|
+ caption,
|
|
idTime,
|
|
idTime,
|
|
companionIdFlow: userId,
|
|
companionIdFlow: userId,
|
|
companionId: id,
|
|
companionId: id,
|
|
@@ -370,6 +383,7 @@ const videoMessage = async (req, res, next) => {
|
|
number,
|
|
number,
|
|
type: 'video',
|
|
type: 'video',
|
|
fullType,
|
|
fullType,
|
|
|
|
+ caption,
|
|
idTime,
|
|
idTime,
|
|
companionIdFlow: userId,
|
|
companionIdFlow: userId,
|
|
companionId: userId,
|
|
companionId: userId,
|
|
@@ -409,7 +423,9 @@ const videoMessage = async (req, res, next) => {
|
|
const fileMessage = async (req, res, next) => {
|
|
const fileMessage = async (req, res, next) => {
|
|
try {
|
|
try {
|
|
const userId = req.user.id;
|
|
const userId = req.user.id;
|
|
- const id = req.params.companionId;
|
|
|
|
|
|
+ const [id, ...rest] = req.params.companionIdAndCaption.split(' ');
|
|
|
|
+ let caption = rest.join(' ');
|
|
|
|
+ if (caption.length === 1) caption.slice(0, -1);
|
|
const idTime = Math.round(Date.now() / 1000);
|
|
const idTime = Math.round(Date.now() / 1000);
|
|
const isChat = await ChatModel.getByField(id, userId);
|
|
const isChat = await ChatModel.getByField(id, userId);
|
|
const isCompanionChat = await ChatModel.getByField(userId, id);
|
|
const isCompanionChat = await ChatModel.getByField(userId, id);
|
|
@@ -451,6 +467,7 @@ const fileMessage = async (req, res, next) => {
|
|
number,
|
|
number,
|
|
type,
|
|
type,
|
|
fullType,
|
|
fullType,
|
|
|
|
+ caption,
|
|
idTime,
|
|
idTime,
|
|
companionIdFlow: userId,
|
|
companionIdFlow: userId,
|
|
companionId: id,
|
|
companionId: id,
|
|
@@ -465,6 +482,7 @@ const fileMessage = async (req, res, next) => {
|
|
number,
|
|
number,
|
|
type,
|
|
type,
|
|
fullType,
|
|
fullType,
|
|
|
|
+ caption,
|
|
idTime,
|
|
idTime,
|
|
companionIdFlow: userId,
|
|
companionIdFlow: userId,
|
|
companionId: userId,
|
|
companionId: userId,
|