Automated Action 545563e776 Implement comprehensive real-time chat API with NestJS
- 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.
2025-06-21 17:13:05 +00:00

104 lines
3.5 KiB
JavaScript

import parsePhoneNumber_ from '../parsePhoneNumber.js'
import PhoneNumber from '../PhoneNumber.js'
import metadata from '../../metadata.min.json' assert { type: 'json' }
function parsePhoneNumber(...parameters) {
parameters.push(metadata)
return parsePhoneNumber_.apply(this, parameters)
}
describe('extractPhoneContext', function() {
it('should parse RFC 3966 phone number URIs', function() {
// context = ";phone-context=" descriptor
// descriptor = domainname / global-number-digits
const NZ_NUMBER = new PhoneNumber('64', '33316005', metadata)
// Valid global-phone-digits
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=+64'),
NZ_NUMBER
)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=+64;{this isn\'t part of phone-context anymore!}'),
NZ_NUMBER
)
const nzFromPhoneContext = new PhoneNumber('64', '3033316005', metadata)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=+64-3'),
nzFromPhoneContext
)
const brFromPhoneContext = new PhoneNumber('55', '5033316005', metadata)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=+(555)'),
brFromPhoneContext
)
const usFromPhoneContext = new PhoneNumber('1', '23033316005', metadata)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=+-1-2.3()'),
usFromPhoneContext
)
// Valid domainname.
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=abc.nz', 'NZ'),
NZ_NUMBER
)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=www.PHONE-numb3r.com', 'NZ'),
NZ_NUMBER
)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=a', 'NZ'),
NZ_NUMBER
)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=3phone.J.', 'NZ'),
NZ_NUMBER
)
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;phone-context=a--z', 'NZ'),
NZ_NUMBER
)
// Should strip ISDN subaddress.
expectPhoneNumbersToBeEqual(
parsePhoneNumber('tel:033316005;isub=/@;phone-context=+64', 'NZ'),
NZ_NUMBER
)
// // Should support incorrectly-written RFC 3966 phone numbers:
// // the ones written without a `tel:` prefix.
// expectPhoneNumbersToBeEqual(
// parsePhoneNumber('033316005;phone-context=+64', 'NZ'),
// NZ_NUMBER
// )
// Invalid descriptor.
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=+')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=64')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=++64')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=+abc')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=.')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=3phone')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=a-.nz')
expectToThrowForInvalidPhoneContext('tel:033316005;phone-context=a{b}c')
})
})
function expectToThrowForInvalidPhoneContext(string) {
expect(parsePhoneNumber(string)).to.be.undefined
}
function expectPhoneNumbersToBeEqual(phoneNumber1, phoneNumber2) {
if (!phoneNumber1 || !phoneNumber2) {
return false
}
return phoneNumber1.number === phoneNumber2.number &&
phoneNumber1.ext === phoneNumber2.ext
}