
- 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.
73 lines
1.9 KiB
JavaScript
73 lines
1.9 KiB
JavaScript
'use strict'
|
|
var stringWidth = require('string-width')
|
|
|
|
module.exports = TemplateItem
|
|
|
|
function isPercent (num) {
|
|
if (typeof num !== 'string') return false
|
|
return num.slice(-1) === '%'
|
|
}
|
|
|
|
function percent (num) {
|
|
return Number(num.slice(0, -1)) / 100
|
|
}
|
|
|
|
function TemplateItem (values, outputLength) {
|
|
this.overallOutputLength = outputLength
|
|
this.finished = false
|
|
this.type = null
|
|
this.value = null
|
|
this.length = null
|
|
this.maxLength = null
|
|
this.minLength = null
|
|
this.kerning = null
|
|
this.align = 'left'
|
|
this.padLeft = 0
|
|
this.padRight = 0
|
|
this.index = null
|
|
this.first = null
|
|
this.last = null
|
|
if (typeof values === 'string') {
|
|
this.value = values
|
|
} else {
|
|
for (var prop in values) this[prop] = values[prop]
|
|
}
|
|
// Realize percents
|
|
if (isPercent(this.length)) {
|
|
this.length = Math.round(this.overallOutputLength * percent(this.length))
|
|
}
|
|
if (isPercent(this.minLength)) {
|
|
this.minLength = Math.round(this.overallOutputLength * percent(this.minLength))
|
|
}
|
|
if (isPercent(this.maxLength)) {
|
|
this.maxLength = Math.round(this.overallOutputLength * percent(this.maxLength))
|
|
}
|
|
return this
|
|
}
|
|
|
|
TemplateItem.prototype = {}
|
|
|
|
TemplateItem.prototype.getBaseLength = function () {
|
|
var length = this.length
|
|
if (length == null && typeof this.value === 'string' && this.maxLength == null && this.minLength == null) {
|
|
length = stringWidth(this.value)
|
|
}
|
|
return length
|
|
}
|
|
|
|
TemplateItem.prototype.getLength = function () {
|
|
var length = this.getBaseLength()
|
|
if (length == null) return null
|
|
return length + this.padLeft + this.padRight
|
|
}
|
|
|
|
TemplateItem.prototype.getMaxLength = function () {
|
|
if (this.maxLength == null) return null
|
|
return this.maxLength + this.padLeft + this.padRight
|
|
}
|
|
|
|
TemplateItem.prototype.getMinLength = function () {
|
|
if (this.minLength == null) return null
|
|
return this.minLength + this.padLeft + this.padRight
|
|
}
|