reels
This commit is contained in:
33
index.js
33
index.js
@@ -217,6 +217,7 @@ const {
|
||||
} = require('./helpers/expiredMessages')
|
||||
const { purgeInactiveChatRooms } = require('./controllers/application/chatRooms/chatRoomHelpers')
|
||||
const { trackOfferMessageForCommission } = require('./utils/offerReplyGate')
|
||||
const { needsUsernameAndPassword } = require('./utils/authSteps')
|
||||
const {
|
||||
parseViewOnce,
|
||||
isViewOnceMediaType,
|
||||
@@ -302,6 +303,22 @@ app.post('/api/v1/chat', [blockCheck, chatPeerBlock], async (req, res) => {
|
||||
return res.status(422).json({ error: 'receiverId is required' })
|
||||
}
|
||||
|
||||
if (needsUsernameAndPassword(req.user)) {
|
||||
const alreadyChatting = await MessageModel.exists({
|
||||
$or: [
|
||||
{ senderId, receiverId },
|
||||
{ senderId: receiverId, receiverId: senderId }
|
||||
]
|
||||
})
|
||||
if (!alreadyChatting) {
|
||||
return res.status(403).json({
|
||||
error: true,
|
||||
type: 'needs_username_password',
|
||||
message: 'برای ارسال اولین پیام باید نامکاربری و رمز عبور خود را تکمیل کنید'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const payload = {
|
||||
senderId,
|
||||
receiverId,
|
||||
@@ -412,6 +429,22 @@ app.post('/api/v1/chat/file', [blockCheck, chatPeerBlock], async (req, res) => {
|
||||
return res.status(422).json({ error: 'receiverId is required' })
|
||||
}
|
||||
|
||||
if (needsUsernameAndPassword(req.user)) {
|
||||
const alreadyChatting = await MessageModel.exists({
|
||||
$or: [
|
||||
{ senderId, receiverId },
|
||||
{ senderId: receiverId, receiverId: senderId }
|
||||
]
|
||||
})
|
||||
if (!alreadyChatting) {
|
||||
return res.status(403).json({
|
||||
error: true,
|
||||
type: 'needs_username_password',
|
||||
message: 'برای ارسال اولین پیام باید نامکاربری و رمز عبور خود را تکمیل کنید'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (viewOnceFlag && !isViewOnceMediaType(resolvedFileType)) {
|
||||
return res.status(422).json({ error: 'View once is only for image, video, and voice' })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user