@@ -21,7 +21,8 @@ export let server; // = http.createServer(app);
2121import { Server } from 'socket.io' ;
2222
2323import nodefetch from "node-fetch" ;
24- const { FormData, fileFrom } = nodefetch ;
24+
25+ const { FormData, fileFrom} = nodefetch ;
2526const fetch = nodefetch . default ;
2627
2728import getSize from 'get-folder-size' ;
@@ -75,19 +76,19 @@ export let socketToIP = [];
7576
7677export let allowLogging = false ;
7778export let debugmode = false ;
78- export let versionCode = 745 ;
79+ export let versionCode = 756 ;
7980
8081// dSync Libs
8182import dSyncAuth from '@hackthedev/dsync-auth' ;
8283//import dSyncAuth from '../../../dSyncAuth/index.mjs';
83- import { dSyncSign } from "@hackthedev/dsync-sign" ;
84+ import { dSyncSign } from "@hackthedev/dsync-sign" ;
8485//import { dSyncSign } from "../dSyncSign/index.mjs"
8586import dSync from "@hackthedev/dsync" ;
8687
8788export let syncer = new dSync ( "dcts" , app )
8889export const signer = new dSyncSign ( ) ;
89- export const auther = new dSyncAuth ( app , signer , async function ( data ) {
90- if ( data . valid === true ) {
90+ export const auther = new dSyncAuth ( app , signer , async function ( data ) {
91+ if ( data . valid === true ) {
9192 changeKeyVerification ( data . publicKey , data . valid ) ;
9293 }
9394} ) ;
@@ -208,10 +209,9 @@ const registerPluginSocketEvents = async (socket, pluginSocketsDir) => {
208209 const fileUrl = pathToFileURL ( filePath ) . href ;
209210 const { default : handler } = await import ( fileUrl ) ;
210211
211- try {
212+ try {
212213 handler ( socket ) ;
213- }
214- catch ( e ) {
214+ } catch ( e ) {
215215 Logger . error ( fileUrl )
216216 Logger . error ( e )
217217 }
@@ -253,7 +253,7 @@ const processPlugins = async () => {
253253 for ( const pluginName of pluginDirs ) {
254254
255255 // ignore files
256- if ( fs . lstatSync ( path . join ( pluginsDir , pluginName ) ) . isFile ( ) === true ) continue ;
256+ if ( fs . lstatSync ( path . join ( pluginsDir , pluginName ) ) . isFile ( ) === true ) continue ;
257257
258258 const pluginDir = path . join ( pluginsDir , pluginName ) ;
259259 const pluginFunctionsDir = path . join ( pluginDir , 'functions' ) ;
@@ -263,7 +263,7 @@ const processPlugins = async () => {
263263 let pluginConfigPath = path . join ( pluginDir , 'config.json' ) ;
264264 let pluginConfig = null ;
265265
266- if ( fs . existsSync ( pluginConfigPath ) ) {
266+ if ( fs . existsSync ( pluginConfigPath ) ) {
267267 pluginConfig = JSON . parse ( fs . readFileSync ( pluginConfigPath ) ) ;
268268 }
269269
@@ -274,7 +274,7 @@ const processPlugins = async () => {
274274 let pluginVersion = pluginConfig ?. version || 0 ;
275275
276276 // skip disabled plugin
277- if ( pluginEnabled !== true ) {
277+ if ( pluginEnabled !== true ) {
278278 Logger . warn ( `Skipped loading plugin ${ pluginTitle } (${ pluginName } ) because its not enabled` )
279279 continue ;
280280 }
@@ -325,10 +325,11 @@ if (serverconfig.serverinfo.sql.enabled == true) {
325325 { name : 'authorId' , type : 'varchar(100) NOT NULL' } ,
326326 { name : 'messageId' , type : 'varchar(100) NOT NULL' } ,
327327 { name : 'room' , type : 'text NOT NULL' } ,
328- { name : 'message' , type : 'longtext NOT NULL' }
328+ { name : 'message' , type : 'longtext NOT NULL' } ,
329+ { name : 'createdAt' , type : 'bigint NOT NULL DEFAULT (UNIX_TIMESTAMP() * 1000)' }
329330 ] ,
330331 keys : [
331- { name : 'UNIQUE KEY' , type : 'messageId (messageId)' }
332+ { name : 'UNIQUE KEY' , type : 'messageId (messageId)' } ,
332333 ]
333334 } ,
334335 {
@@ -698,30 +699,29 @@ server.listen(port, function () {
698699} ) ;
699700
700701
701-
702702const API_KEY = serverconfig . serverinfo . livekit . key ;
703703const API_SECRET = serverconfig . serverinfo . livekit . secret ;
704704
705705const webhookReceiver = new WebhookReceiver ( API_KEY , API_SECRET ) ;
706706
707707// --- Token Endpoint ---
708- app . post ( "/token" , async ( req , res ) => {
709- const { roomName, participantName } = req . body ;
708+ app . post ( "/token" , async ( req , res ) => {
709+ const { roomName, participantName} = req . body ;
710710
711711 if ( ! roomName || ! participantName ) {
712- res . status ( 400 ) . json ( { errorMessage : "roomName and participantName are required" } ) ;
712+ res . status ( 400 ) . json ( { errorMessage : "roomName and participantName are required" } ) ;
713713 return ;
714714 }
715715
716- const at = new AccessToken ( API_KEY , API_SECRET , { identity : participantName } ) ;
717- at . addGrant ( { roomJoin : true , room : roomName } ) ;
716+ const at = new AccessToken ( API_KEY , API_SECRET , { identity : participantName } ) ;
717+ at . addGrant ( { roomJoin : true , room : roomName } ) ;
718718 const token = await at . toJwt ( ) ;
719719
720- res . json ( { token } ) ;
720+ res . json ( { token} ) ;
721721} ) ;
722722
723723// --- Webhook Endpoint ---
724- app . post ( "/livekit/webhook" , express . raw ( { type : "*/*" } ) , async ( req , res ) => {
724+ app . post ( "/livekit/webhook" , express . raw ( { type : "*/*" } ) , async ( req , res ) => {
725725 try {
726726 const event = await webhookReceiver . receive ( req . body , req . get ( "Authorization" ) ) ;
727727 console . log ( event ) ;
@@ -732,7 +732,6 @@ app.post("/livekit/webhook", express.raw({ type: "*/*" }), async (req, res) => {
732732} ) ;
733733
734734
735-
736735//app.use(express.urlencoded({extended: true})); // Parses URL-encoded data
737736registerTemplateMiddleware ( app , __dirname , fs , path , serverconfig ) ;
738737app . use (
@@ -747,7 +746,6 @@ app.use(
747746) ;
748747
749748
750-
751749// Process plugins at server start
752750processPlugins ( ) . catch ( err => console . error ( err ) ) ;
753751
@@ -822,7 +820,7 @@ const registerSocketEvents = (socket) => {
822820 }
823821} ) ( ) ;
824822
825- export async function checkPow ( socket ) {
823+ export async function checkPow ( socket ) {
826824 if ( powVerifiedUsers . includes ( socket . id ) ) {
827825 socket . powValidated = true ;
828826 return ;
0 commit comments