UNPKG

@sync-in/server

Version:

The secure, open-source platform for file storage, sharing, collaboration, and sync

45 lines (44 loc) 2.02 kB
/* * Copyright (C) 2012-2025 Johan Legrand <johan.legrand@sync-in.com> * This file is part of Sync-in | The open source file sync and share solution * See the LICENSE file for licensing details */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "WebSocketNotifications", { enumerable: true, get: function() { return WebSocketNotifications; } }); const _websockets = require("@nestjs/websockets"); const _socketio = require("socket.io"); const _websocket = require("../users/constants/websocket"); const _websocket1 = require("./constants/websocket"); function _ts_decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function _ts_metadata(k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); } let WebSocketNotifications = class WebSocketNotifications { sendMessageToUsers(userIds, eventName, body) { if (userIds.length) { this.server.to(userIds.map((uid)=>`${_websocket.USER_ROOM_PREFIX}${uid}`)).emit(eventName, body); } } }; _ts_decorate([ (0, _websockets.WebSocketServer)(), _ts_metadata("design:type", typeof _socketio.Server === "undefined" ? Object : _socketio.Server) ], WebSocketNotifications.prototype, "server", void 0); WebSocketNotifications = _ts_decorate([ (0, _websockets.WebSocketGateway)({ namespace: _websocket1.NOTIFICATIONS_WS.NAME_SPACE }) ], WebSocketNotifications); //# sourceMappingURL=notifications.gateway.js.map