@eleven-am/pondsocket 0.1.116 → 0.1.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/nest.js +13 -3
- package/package.json +1 -1
package/nest.js
CHANGED
|
@@ -263,14 +263,19 @@ class Context {
|
|
|
263
263
|
return (_a = this.data[key]) !== null && _a !== void 0 ? _a : null;
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
function manageResponse(data, channel, response) {
|
|
266
|
+
function manageResponse(data, channel, clientId, response) {
|
|
267
267
|
if (response && response.hasResponded || !isNotEmpty(data)) {
|
|
268
268
|
return;
|
|
269
269
|
}
|
|
270
270
|
const { event, presence, updatePresence, assigns, broadcast } = data, rest = __rest(data, ["event", "presence", "updatePresence", "assigns", "broadcast"]);
|
|
271
271
|
if (response) {
|
|
272
272
|
if (event && typeof event === 'string' && isNotEmpty(rest)) {
|
|
273
|
-
response.
|
|
273
|
+
if (clientId && response instanceof eventResponse_1.EventResponse && !isNotEmpty(assigns)) {
|
|
274
|
+
response.sendToUsers(event, rest, [clientId]);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
response.send(event, rest, assigns);
|
|
278
|
+
}
|
|
274
279
|
}
|
|
275
280
|
else if (isNotEmpty(assigns)) {
|
|
276
281
|
response.accept(assigns);
|
|
@@ -537,23 +542,28 @@ function manageAction(instance, moduleRef, originalMethod, propertyKey, leaveEve
|
|
|
537
542
|
const req = {};
|
|
538
543
|
const res = {};
|
|
539
544
|
let channel = null;
|
|
545
|
+
let clientId = null;
|
|
540
546
|
if (request && response) {
|
|
541
547
|
if (request instanceof joinRequest_1.JoinRequest && response instanceof joinResponse_1.JoinResponse) {
|
|
542
548
|
channel = request.channel;
|
|
549
|
+
clientId = request.user.id;
|
|
543
550
|
req.joinRequest = request;
|
|
544
551
|
res.joinResponse = response;
|
|
545
552
|
}
|
|
546
553
|
else if (request instanceof eventRequest_1.EventRequest && response instanceof eventResponse_1.EventResponse) {
|
|
547
554
|
channel = request.channel;
|
|
555
|
+
clientId = request.user.id;
|
|
548
556
|
req.eventRequest = request;
|
|
549
557
|
res.eventResponse = response;
|
|
550
558
|
}
|
|
551
559
|
else if ('headers' in request && response instanceof response_1.ConnectionResponse) {
|
|
560
|
+
clientId = request.id;
|
|
552
561
|
req.connection = request;
|
|
553
562
|
res.connection = response;
|
|
554
563
|
}
|
|
555
564
|
}
|
|
556
565
|
else if (leaveEvent) {
|
|
566
|
+
clientId = leaveEvent.userId;
|
|
557
567
|
channel = leaveEvent.channel;
|
|
558
568
|
req.leveeEvent = leaveEvent;
|
|
559
569
|
}
|
|
@@ -561,7 +571,7 @@ function manageAction(instance, moduleRef, originalMethod, propertyKey, leaveEve
|
|
|
561
571
|
const canProceed = yield resolveGuards(moduleRef, context);
|
|
562
572
|
if (canProceed) {
|
|
563
573
|
const data = yield originalMethod.apply(instance, resolveParameters(context));
|
|
564
|
-
manageResponse(data, channel, response);
|
|
574
|
+
manageResponse(data, channel, clientId, response);
|
|
565
575
|
}
|
|
566
576
|
else if (response) {
|
|
567
577
|
response.reject('Unauthorized', 401);
|