feat: новая функция
This commit is contained in:
@@ -460,17 +460,18 @@ class UniversalGuestService {
|
||||
attachment_mimetype_encrypted,
|
||||
attachment_size,
|
||||
attachment_data,
|
||||
message_type,
|
||||
created_at
|
||||
) VALUES (
|
||||
$1, $2,
|
||||
encrypt_text($3, $13),
|
||||
encrypt_text($4, $13),
|
||||
encrypt_text($5, $13),
|
||||
encrypt_text($6, $13),
|
||||
encrypt_text($7, $13),
|
||||
encrypt_text($8, $13),
|
||||
encrypt_text($9, $13),
|
||||
$10, $11, $12
|
||||
encrypt_text($3, $14),
|
||||
encrypt_text($4, $14),
|
||||
encrypt_text($5, $14),
|
||||
encrypt_text($6, $14),
|
||||
encrypt_text($7, $14),
|
||||
encrypt_text($8, $14),
|
||||
encrypt_text($9, $14),
|
||||
$10, $11, $12, $13
|
||||
)`,
|
||||
[
|
||||
userId,
|
||||
@@ -484,6 +485,7 @@ class UniversalGuestService {
|
||||
msg.attachment_mimetype,
|
||||
msg.attachment_size,
|
||||
msg.attachment_data,
|
||||
'public', // message_type для мигрированных сообщений
|
||||
msg.created_at,
|
||||
encryptionKey
|
||||
]
|
||||
|
||||
@@ -29,18 +29,13 @@ const logger = require('../utils/logger');
|
||||
function shouldGenerateAiReply(params) {
|
||||
const { senderType, userId, recipientId } = params;
|
||||
|
||||
// Обычные пользователи всегда получают AI ответ
|
||||
// Обычные пользователи (USER, READONLY) всегда получают AI ответ
|
||||
if (senderType !== 'editor') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Админ, пишущий себе, получает AI ответ
|
||||
if (userId === recipientId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Админ, пишущий другому пользователю, не получает AI ответ
|
||||
// (это личное сообщение от админа)
|
||||
// Админы-редакторы (EDITOR) НЕ получают AI ответы
|
||||
// ни себе, ни другим админам (по спецификации)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -130,9 +130,16 @@ class SessionService {
|
||||
*/
|
||||
async isGuestIdProcessed(guestId) {
|
||||
try {
|
||||
const result = await encryptedDb.getData('unified_guest_mapping', { identifier_encrypted: `web:${guestId}` });
|
||||
const encryptionUtils = require('../utils/encryptionUtils');
|
||||
const encryptionKey = encryptionUtils.getEncryptionKey();
|
||||
|
||||
return result.length > 0 && result[0].processed === true;
|
||||
const result = await db.getQuery()(
|
||||
`SELECT * FROM unified_guest_mapping
|
||||
WHERE decrypt_text(identifier_encrypted, $2) = $1 AND processed = true`,
|
||||
[`web:${guestId}`, encryptionKey]
|
||||
);
|
||||
|
||||
return result.rows.length > 0;
|
||||
} catch (error) {
|
||||
logger.error(`[isGuestIdProcessed] Error checking guest ID ${guestId}:`, error);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user