
- Complete NestJS TypeScript implementation with WebSocket support - Direct messaging (DM) and group chat functionality - End-to-end encryption with AES encryption and key pairs - Media file support (images, videos, audio, documents) up to 100MB - Push notifications with Firebase Cloud Messaging integration - Mention alerts and real-time typing indicators - User authentication with JWT and Passport - SQLite database with TypeORM entities and relationships - Comprehensive API documentation with Swagger/OpenAPI - File upload handling with secure access control - Online/offline status tracking and presence management - Message editing, deletion, and reply functionality - Notification management with automatic cleanup - Health check endpoint for monitoring - CORS configuration for cross-origin requests - Environment-based configuration management - Structured for Flutter SDK integration Features implemented: ✅ Real-time messaging with Socket.IO ✅ User registration and authentication ✅ Direct messages and group chats ✅ Media file uploads and management ✅ End-to-end encryption ✅ Push notifications ✅ Mention alerts ✅ Typing indicators ✅ Message read receipts ✅ Online status tracking ✅ File access control ✅ Comprehensive API documentation Ready for Flutter SDK development and production deployment.
55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
import isObject from './helpers/isObject.js'
|
|
|
|
// Extracts the following properties from function arguments:
|
|
// * input `text`
|
|
// * `options` object
|
|
// * `metadata` JSON
|
|
export default function normalizeArguments(args) {
|
|
const [arg_1, arg_2, arg_3, arg_4] = Array.prototype.slice.call(args)
|
|
|
|
let text
|
|
let options
|
|
let metadata
|
|
|
|
// If the phone number is passed as a string.
|
|
// `parsePhoneNumber('88005553535', ...)`.
|
|
if (typeof arg_1 === 'string') {
|
|
text = arg_1
|
|
}
|
|
else throw new TypeError('A text for parsing must be a string.')
|
|
|
|
// If "default country" argument is being passed then move it to `options`.
|
|
// `parsePhoneNumber('88005553535', 'RU', [options], metadata)`.
|
|
if (!arg_2 || typeof arg_2 === 'string')
|
|
{
|
|
if (arg_4) {
|
|
options = arg_3
|
|
metadata = arg_4
|
|
} else {
|
|
options = undefined
|
|
metadata = arg_3
|
|
}
|
|
|
|
if (arg_2) {
|
|
options = { defaultCountry: arg_2, ...options }
|
|
}
|
|
}
|
|
// `defaultCountry` is not passed.
|
|
// Example: `parsePhoneNumber('+78005553535', [options], metadata)`.
|
|
else if (isObject(arg_2))
|
|
{
|
|
if (arg_3) {
|
|
options = arg_2
|
|
metadata = arg_3
|
|
} else {
|
|
metadata = arg_2
|
|
}
|
|
}
|
|
else throw new Error(`Invalid second argument: ${arg_2}`)
|
|
|
|
return {
|
|
text,
|
|
options,
|
|
metadata
|
|
}
|
|
} |