ncloudchat 1.0.31 → 1.0.35
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/LICENSE.md +2 -2
- package/README.md +23 -393
- package/ncloudchat.d.ts +1298 -0
- package/ncloudchat.min.js +1 -0
- package/package.json +19 -39
- package/deploy.sh +0 -20
- package/esm/CloudChat.d.ts +0 -481
- package/esm/CloudChat.js +0 -1735
- package/esm/CloudChat.js.map +0 -1
- package/esm/CoreManager.d.ts +0 -11
- package/esm/CoreManager.js +0 -36
- package/esm/CoreManager.js.map +0 -1
- package/esm/Dispatcher.d.ts +0 -37
- package/esm/Dispatcher.js +0 -93
- package/esm/Dispatcher.js.map +0 -1
- package/esm/Network.d.ts +0 -7
- package/esm/Network.js +0 -93
- package/esm/Network.js.map +0 -1
- package/esm/Type.d.ts +0 -79
- package/esm/Type.js +0 -28
- package/esm/Type.js.map +0 -1
- package/esm/Util.d.ts +0 -15
- package/esm/Util.js +0 -20
- package/esm/Util.js.map +0 -1
- package/esm/graphql/channel.d.ts +0 -13
- package/esm/graphql/channel.js +0 -16
- package/esm/graphql/channel.js.map +0 -1
- package/esm/graphql/friend.d.ts +0 -11
- package/esm/graphql/friend.js +0 -13
- package/esm/graphql/friend.js.map +0 -1
- package/esm/graphql/invite.d.ts +0 -7
- package/esm/graphql/invite.js +0 -8
- package/esm/graphql/invite.js.map +0 -1
- package/esm/graphql/member.d.ts +0 -11
- package/esm/graphql/member.js +0 -13
- package/esm/graphql/member.js.map +0 -1
- package/esm/graphql/message.d.ts +0 -11
- package/esm/graphql/message.js +0 -13
- package/esm/graphql/message.js.map +0 -1
- package/esm/graphql/pin.d.ts +0 -10
- package/esm/graphql/pin.js +0 -12
- package/esm/graphql/pin.js.map +0 -1
- package/esm/graphql/project.d.ts +0 -7
- package/esm/graphql/project.js +0 -8
- package/esm/graphql/project.js.map +0 -1
- package/esm/graphql/subscription.d.ts +0 -11
- package/esm/graphql/subscription.js +0 -13
- package/esm/graphql/subscription.js.map +0 -1
- package/esm/index.d.ts +0 -8
- package/esm/index.js +0 -9
- package/esm/index.js.map +0 -1
- package/esm/logger.d.ts +0 -10
- package/esm/logger.js +0 -17
- package/esm/logger.js.map +0 -1
- package/esm/mutations/channel.d.ts +0 -56
- package/esm/mutations/channel.js +0 -170
- package/esm/mutations/channel.js.map +0 -1
- package/esm/mutations/friend.d.ts +0 -42
- package/esm/mutations/friend.js +0 -122
- package/esm/mutations/friend.js.map +0 -1
- package/esm/mutations/index.d.ts +0 -13
- package/esm/mutations/index.js +0 -14
- package/esm/mutations/index.js.map +0 -1
- package/esm/mutations/invite.d.ts +0 -16
- package/esm/mutations/invite.js +0 -67
- package/esm/mutations/invite.js.map +0 -1
- package/esm/mutations/member.d.ts +0 -41
- package/esm/mutations/member.js +0 -129
- package/esm/mutations/member.js.map +0 -1
- package/esm/mutations/message.d.ts +0 -37
- package/esm/mutations/message.js +0 -130
- package/esm/mutations/message.js.map +0 -1
- package/esm/mutations/pin.d.ts +0 -28
- package/esm/mutations/pin.js +0 -88
- package/esm/mutations/pin.js.map +0 -1
- package/esm/mutations/subscription.d.ts +0 -37
- package/esm/mutations/subscription.js +0 -115
- package/esm/mutations/subscription.js.map +0 -1
- package/esm/queries/channel.d.ts +0 -26
- package/esm/queries/channel.js +0 -88
- package/esm/queries/channel.js.map +0 -1
- package/esm/queries/friend.d.ts +0 -17
- package/esm/queries/friend.js +0 -69
- package/esm/queries/friend.js.map +0 -1
- package/esm/queries/index.d.ts +0 -14
- package/esm/queries/index.js +0 -15
- package/esm/queries/index.js.map +0 -1
- package/esm/queries/member.d.ts +0 -17
- package/esm/queries/member.js +0 -69
- package/esm/queries/member.js.map +0 -1
- package/esm/queries/memberblocks.d.ts +0 -17
- package/esm/queries/memberblocks.js +0 -69
- package/esm/queries/memberblocks.js.map +0 -1
- package/esm/queries/message.d.ts +0 -36
- package/esm/queries/message.js +0 -109
- package/esm/queries/message.js.map +0 -1
- package/esm/queries/pin.d.ts +0 -28
- package/esm/queries/pin.js +0 -92
- package/esm/queries/pin.js.map +0 -1
- package/esm/queries/project.d.ts +0 -14
- package/esm/queries/project.js +0 -63
- package/esm/queries/project.js.map +0 -1
- package/esm/queries/subscription.d.ts +0 -27
- package/esm/queries/subscription.js +0 -90
- package/esm/queries/subscription.js.map +0 -1
- package/lib/CloudChat.js +0 -2658
- package/lib/CoreManager.js +0 -45
- package/lib/Dispatcher.js +0 -125
- package/lib/Network.js +0 -226
- package/lib/Type.js +0 -44
- package/lib/Util.js +0 -32
- package/lib/graphql/channel.js +0 -32
- package/lib/graphql/friend.js +0 -27
- package/lib/graphql/invite.js +0 -18
- package/lib/graphql/member.js +0 -27
- package/lib/graphql/message.js +0 -27
- package/lib/graphql/pin.js +0 -25
- package/lib/graphql/project.js +0 -18
- package/lib/graphql/subscription.js +0 -27
- package/lib/index.js +0 -18
- package/lib/logger.js +0 -33
- package/lib/mutations/channel.js +0 -354
- package/lib/mutations/friend.js +0 -299
- package/lib/mutations/index.js +0 -109
- package/lib/mutations/invite.js +0 -205
- package/lib/mutations/member.js +0 -304
- package/lib/mutations/message.js +0 -298
- package/lib/mutations/pin.js +0 -229
- package/lib/mutations/subscription.js +0 -281
- package/lib/queries/channel.js +0 -239
- package/lib/queries/friend.js +0 -207
- package/lib/queries/index.js +0 -123
- package/lib/queries/member.js +0 -207
- package/lib/queries/memberblocks.js +0 -207
- package/lib/queries/message.js +0 -273
- package/lib/queries/pin.js +0 -243
- package/lib/queries/project.js +0 -201
- package/lib/queries/subscription.js +0 -241
- package/ncloudchat_javascript.md +0 -289
- package/tsconfig.json +0 -32
- package/types/exif.d.ts +0 -10
- package/types/window.d.ts +0 -5
- package//353/260/260/355/217/254/354/210/234/354/204/234.md +0 -8
package/esm/CloudChat.js
DELETED
|
@@ -1,1735 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) NBASE CORP. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
var __assign = (this && this.__assign) || function () {
|
|
8
|
-
__assign = Object.assign || function(t) {
|
|
9
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
10
|
-
s = arguments[i];
|
|
11
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
12
|
-
t[p] = s[p];
|
|
13
|
-
}
|
|
14
|
-
return t;
|
|
15
|
-
};
|
|
16
|
-
return __assign.apply(this, arguments);
|
|
17
|
-
};
|
|
18
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
19
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
20
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
21
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
22
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
23
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
24
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
28
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
29
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
30
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
31
|
-
function step(op) {
|
|
32
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
33
|
-
while (_) try {
|
|
34
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
35
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
36
|
-
switch (op[0]) {
|
|
37
|
-
case 0: case 1: t = op; break;
|
|
38
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
39
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
40
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
41
|
-
default:
|
|
42
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
43
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
44
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
45
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
46
|
-
if (t[2]) _.ops.pop();
|
|
47
|
-
_.trys.pop(); continue;
|
|
48
|
-
}
|
|
49
|
-
op = body.call(thisArg, _);
|
|
50
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
51
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var __values = (this && this.__values) || function(o) {
|
|
55
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
56
|
-
if (m) return m.call(o);
|
|
57
|
-
if (o && typeof o.length === "number") return {
|
|
58
|
-
next: function () {
|
|
59
|
-
if (o && i >= o.length) o = void 0;
|
|
60
|
-
return { value: o && o[i++], done: !o };
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
64
|
-
};
|
|
65
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
66
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
67
|
-
if (!m) return o;
|
|
68
|
-
var i = m.call(o), r, ar = [], e;
|
|
69
|
-
try {
|
|
70
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
71
|
-
}
|
|
72
|
-
catch (error) { e = { error: error }; }
|
|
73
|
-
finally {
|
|
74
|
-
try {
|
|
75
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
76
|
-
}
|
|
77
|
-
finally { if (e) throw e.error; }
|
|
78
|
-
}
|
|
79
|
-
return ar;
|
|
80
|
-
};
|
|
81
|
-
import { io } from "socket.io-client";
|
|
82
|
-
import CoreManager from "./CoreManager";
|
|
83
|
-
import Dispatcher from "./Dispatcher";
|
|
84
|
-
import { info } from "./logger";
|
|
85
|
-
import { getChannel, getChannels, getMessage, getMessages, getSubscription, getSubscriptions, getMembers, getMemberBlocks, getFriendships, unreadCount, getPin, getPins } from "./queries";
|
|
86
|
-
import { login, createChannel, updateChannel, deleteChannel, translate, message, upload, createSubscription, deleteSubscription, updateSubscription, addChannelMembers, removeChannelMembers, requestFriend, acceptFriend, rejectFriend, removeFriend, createMemberBlock, deleteMemberBlock, createPin, updatePin } from "./mutations";
|
|
87
|
-
/**
|
|
88
|
-
* Class NCloudChat holds all the NCloudChat functionalities.
|
|
89
|
-
*
|
|
90
|
-
* @class
|
|
91
|
-
*/
|
|
92
|
-
var NCloudChat = /** @class */ (function () {
|
|
93
|
-
/**
|
|
94
|
-
* Create a `NCloudChat` instance and a Dispatcher.
|
|
95
|
-
*
|
|
96
|
-
* @constructs
|
|
97
|
-
*/
|
|
98
|
-
function NCloudChat(debug) {
|
|
99
|
-
if (debug === void 0) { debug = false; }
|
|
100
|
-
this.socket = null;
|
|
101
|
-
this.connected = false;
|
|
102
|
-
this.connectedCount = 0;
|
|
103
|
-
this.dp = new Dispatcher();
|
|
104
|
-
if (!debug)
|
|
105
|
-
console.log = function () { };
|
|
106
|
-
}
|
|
107
|
-
NCloudChat.prototype.clear = function () { };
|
|
108
|
-
/**
|
|
109
|
-
* Initialize a new `NCloudChat` instance of project and user.
|
|
110
|
-
*
|
|
111
|
-
* @function initialize
|
|
112
|
-
* @param {string} projectId - The id of a project.
|
|
113
|
-
*/
|
|
114
|
-
NCloudChat.prototype.initialize = function (projectId) {
|
|
115
|
-
this.setProjectId(projectId);
|
|
116
|
-
};
|
|
117
|
-
NCloudChat.prototype.getLang = function () {
|
|
118
|
-
return navigator.language;
|
|
119
|
-
};
|
|
120
|
-
NCloudChat.prototype.getUser = function () {
|
|
121
|
-
return CoreManager.get("USER");
|
|
122
|
-
};
|
|
123
|
-
NCloudChat.prototype.getProjectId = function () {
|
|
124
|
-
return CoreManager.get("PROJECT_ID");
|
|
125
|
-
};
|
|
126
|
-
NCloudChat.prototype.setServerUrl = function (url) {
|
|
127
|
-
if (!/^[hHtTpP]{4}(s)?(:\/\/)[a-zA-Z0-9\.\/-:]+/.test(url)) {
|
|
128
|
-
throw Error("invalied url : (ex)http://domain.com, https://domain.com");
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (url.length > 1 && url.substring(url.length - 1) === "/") {
|
|
132
|
-
url = url.substring(0, url.length - 1);
|
|
133
|
-
}
|
|
134
|
-
return CoreManager.set("SERVER_URL", url);
|
|
135
|
-
};
|
|
136
|
-
NCloudChat.prototype.setSocketUrl = function (url) {
|
|
137
|
-
CoreManager.set("SOCKET_URL", url);
|
|
138
|
-
};
|
|
139
|
-
NCloudChat.prototype.setProjectId = function (projectId) {
|
|
140
|
-
return CoreManager.set("PROJECT_ID", projectId);
|
|
141
|
-
};
|
|
142
|
-
NCloudChat.prototype.setToken = function (token) {
|
|
143
|
-
return CoreManager.set("TOKEN", token);
|
|
144
|
-
};
|
|
145
|
-
NCloudChat.prototype.setUser = function (user) {
|
|
146
|
-
CoreManager.set("USER", user);
|
|
147
|
-
};
|
|
148
|
-
NCloudChat.prototype.inputValidation = function (inputs) {
|
|
149
|
-
var e_1, _a;
|
|
150
|
-
if (!this.isConnected())
|
|
151
|
-
throw Error("You are not connected.");
|
|
152
|
-
try {
|
|
153
|
-
for (var _b = __values(Object.entries(inputs)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
154
|
-
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
155
|
-
if (!value) {
|
|
156
|
-
var result = key.replace(/([A-Z])/g, " $1");
|
|
157
|
-
var word = result.charAt(0).toUpperCase() + result.slice(1);
|
|
158
|
-
throw Error("You need a(n) ".concat(word, "."));
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
163
|
-
finally {
|
|
164
|
-
try {
|
|
165
|
-
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
|
|
166
|
-
}
|
|
167
|
-
finally { if (e_1) throw e_1.error; }
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* Create a connection between a socket and a client.
|
|
172
|
-
*
|
|
173
|
-
* @async connect
|
|
174
|
-
* @param {any} user
|
|
175
|
-
* @param {string} userToken
|
|
176
|
-
* @returns
|
|
177
|
-
*/
|
|
178
|
-
NCloudChat.prototype.connect = function (user, userToken) {
|
|
179
|
-
if (userToken === void 0) { userToken = ""; }
|
|
180
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
181
|
-
var url, image, name, lang, customField, response, e_2, options;
|
|
182
|
-
var _this = this;
|
|
183
|
-
return __generator(this, function (_a) {
|
|
184
|
-
switch (_a.label) {
|
|
185
|
-
case 0:
|
|
186
|
-
if (!this.isConnected()) return [3 /*break*/, 2];
|
|
187
|
-
return [4 /*yield*/, this.disconnect()];
|
|
188
|
-
case 1:
|
|
189
|
-
_a.sent();
|
|
190
|
-
_a.label = 2;
|
|
191
|
-
case 2:
|
|
192
|
-
url = CoreManager.get("SOCKET_URL") + "/cloudchat";
|
|
193
|
-
if (!this.getProjectId())
|
|
194
|
-
throw Error("Project ID not found");
|
|
195
|
-
if (!user.id)
|
|
196
|
-
throw Error("UserID not found");
|
|
197
|
-
image = user.profile;
|
|
198
|
-
name = user.name;
|
|
199
|
-
lang = this.getLang();
|
|
200
|
-
customField = user.customField;
|
|
201
|
-
_a.label = 3;
|
|
202
|
-
case 3:
|
|
203
|
-
_a.trys.push([3, 5, , 6]);
|
|
204
|
-
return [4 /*yield*/, login(user.id, name, image, userToken, customField)];
|
|
205
|
-
case 4:
|
|
206
|
-
response = _a.sent();
|
|
207
|
-
this.setUser({
|
|
208
|
-
id: user.id,
|
|
209
|
-
name: name,
|
|
210
|
-
image: image,
|
|
211
|
-
customField: customField
|
|
212
|
-
});
|
|
213
|
-
userToken = response["token"]; // parse token object
|
|
214
|
-
return [3 /*break*/, 6];
|
|
215
|
-
case 5:
|
|
216
|
-
e_2 = _a.sent();
|
|
217
|
-
throw e_2;
|
|
218
|
-
case 6:
|
|
219
|
-
CoreManager.set("TOKEN", userToken);
|
|
220
|
-
options = {
|
|
221
|
-
transports: ["websocket"],
|
|
222
|
-
reconnection: true,
|
|
223
|
-
reconnectionAttempts: 10,
|
|
224
|
-
reconnectionDelay: 2000,
|
|
225
|
-
reconnectionDelayMax: 2000 * 100,
|
|
226
|
-
randomizationFactor: 0.5,
|
|
227
|
-
query: {
|
|
228
|
-
project_id: this.getProjectId(),
|
|
229
|
-
user_id: user.id,
|
|
230
|
-
lang: lang,
|
|
231
|
-
image: image,
|
|
232
|
-
name: name,
|
|
233
|
-
customField: customField,
|
|
234
|
-
token: userToken
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
this.socket = io(url, options);
|
|
238
|
-
this.socket.on("connect", function (data) {
|
|
239
|
-
_this.connectedCount++;
|
|
240
|
-
_this.connected = true;
|
|
241
|
-
info("Connected to ".concat(url, " with id: ").concat(_this.socket.id));
|
|
242
|
-
_this.dp.dispatch("onConnected", data);
|
|
243
|
-
});
|
|
244
|
-
this.socket.on("unauthorized", function (data) { });
|
|
245
|
-
this.socket.on("disconnect", function (reason) {
|
|
246
|
-
_this.connected = false;
|
|
247
|
-
info("Disconnected to ".concat(url, " with id: ").concat(_this.socket.id));
|
|
248
|
-
_this.dp.dispatch("onDisconnected", reason);
|
|
249
|
-
});
|
|
250
|
-
this.socket.on("message", function (payload) {
|
|
251
|
-
var message = JSON.parse(payload);
|
|
252
|
-
_this.dp.dispatch("onMessageReceived", message.channel_id, message);
|
|
253
|
-
});
|
|
254
|
-
this.socket.on("event", function (payload) {
|
|
255
|
-
var message = JSON.parse(payload);
|
|
256
|
-
_this.dp.dispatch("onEventReceived", message.channel_id, message);
|
|
257
|
-
});
|
|
258
|
-
this.socket.on("start typing", function (payload) {
|
|
259
|
-
var data = JSON.parse(payload);
|
|
260
|
-
_this.dp.dispatch("onStartTyping", data);
|
|
261
|
-
});
|
|
262
|
-
this.socket.on("stop typing", function (payload) {
|
|
263
|
-
var data = JSON.parse(payload);
|
|
264
|
-
_this.dp.dispatch("onStopTyping", data);
|
|
265
|
-
});
|
|
266
|
-
this.socket.on("member joined", function (payload) {
|
|
267
|
-
var data = JSON.parse(payload);
|
|
268
|
-
_this.dp.dispatch("onMemberJoined", data);
|
|
269
|
-
});
|
|
270
|
-
this.socket.on("member leaved", function (payload) {
|
|
271
|
-
var data = JSON.parse(payload);
|
|
272
|
-
_this.dp.dispatch("onMemberLeaved", data);
|
|
273
|
-
});
|
|
274
|
-
this.socket.on("member updated", function (payload) {
|
|
275
|
-
var data = JSON.parse(payload);
|
|
276
|
-
_this.dp.dispatch("onMemberUpdated", data);
|
|
277
|
-
});
|
|
278
|
-
this.socket.on("message deleted", function (payload) {
|
|
279
|
-
var data = JSON.parse(payload);
|
|
280
|
-
_this.dp.dispatch("onMessageDeleted", data);
|
|
281
|
-
});
|
|
282
|
-
this.socket.on("message updated", function (payload) {
|
|
283
|
-
var data = JSON.parse(payload);
|
|
284
|
-
_this.dp.dispatch("onMessageUpdated", data);
|
|
285
|
-
});
|
|
286
|
-
this.socket.on("user banned", function (payload) {
|
|
287
|
-
var data = JSON.parse(payload);
|
|
288
|
-
_this.dp.dispatch("onUserBanned", data);
|
|
289
|
-
});
|
|
290
|
-
this.socket.on("user deleted", function (payload) {
|
|
291
|
-
var data = JSON.parse(payload);
|
|
292
|
-
_this.dp.dispatch("onUserDeleted", data);
|
|
293
|
-
});
|
|
294
|
-
this.socket.on("user updated", function (payload) {
|
|
295
|
-
var data = JSON.parse(payload);
|
|
296
|
-
_this.dp.dispatch("onUserUpdated", data);
|
|
297
|
-
});
|
|
298
|
-
this.socket.on("result", function (payload) {
|
|
299
|
-
var message = JSON.parse(payload);
|
|
300
|
-
_this.dp.dispatch("onResult", message);
|
|
301
|
-
});
|
|
302
|
-
this.socket.on("error", function (payload) {
|
|
303
|
-
var message = JSON.parse(payload);
|
|
304
|
-
_this.dp.dispatch("onErrorReceived", message);
|
|
305
|
-
});
|
|
306
|
-
return [2 /*return*/, user];
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
/**
|
|
312
|
-
* Mute channel notifications.
|
|
313
|
-
*
|
|
314
|
-
* @async
|
|
315
|
-
* @function mute
|
|
316
|
-
* @param {string} channel
|
|
317
|
-
* @returns {Promise<any>}
|
|
318
|
-
*/
|
|
319
|
-
NCloudChat.prototype.mute = function (channel) {
|
|
320
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
321
|
-
var subscription, e_3;
|
|
322
|
-
return __generator(this, function (_a) {
|
|
323
|
-
switch (_a.label) {
|
|
324
|
-
case 0:
|
|
325
|
-
this.inputValidation({ channelId: channel });
|
|
326
|
-
_a.label = 1;
|
|
327
|
-
case 1:
|
|
328
|
-
_a.trys.push([1, 3, , 4]);
|
|
329
|
-
return [4 /*yield*/, updateSubscription(channel, null, JSON.stringify({ mute: true }))];
|
|
330
|
-
case 2:
|
|
331
|
-
subscription = _a.sent();
|
|
332
|
-
if (subscription["subscription"])
|
|
333
|
-
subscription["subscription"]["id"] = this.ObjectId(subscription["subscription"]["id"]);
|
|
334
|
-
return [2 /*return*/, subscription["subscription"]];
|
|
335
|
-
case 3:
|
|
336
|
-
e_3 = _a.sent();
|
|
337
|
-
throw e_3;
|
|
338
|
-
case 4: return [2 /*return*/];
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
};
|
|
343
|
-
/**
|
|
344
|
-
* Unmute channel notifications.
|
|
345
|
-
*
|
|
346
|
-
* @async
|
|
347
|
-
* @function unmute
|
|
348
|
-
* @param {string} channel
|
|
349
|
-
* @returns {Promise<any>}
|
|
350
|
-
*/
|
|
351
|
-
NCloudChat.prototype.unmute = function (channel) {
|
|
352
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
353
|
-
var subscription, e_4;
|
|
354
|
-
return __generator(this, function (_a) {
|
|
355
|
-
switch (_a.label) {
|
|
356
|
-
case 0:
|
|
357
|
-
this.inputValidation({ channelId: channel });
|
|
358
|
-
_a.label = 1;
|
|
359
|
-
case 1:
|
|
360
|
-
_a.trys.push([1, 3, , 4]);
|
|
361
|
-
return [4 /*yield*/, updateSubscription(channel, null, JSON.stringify({ mute: false }))];
|
|
362
|
-
case 2:
|
|
363
|
-
subscription = _a.sent();
|
|
364
|
-
if (subscription["subscription"])
|
|
365
|
-
subscription["subscription"]["id"] = this.ObjectId(subscription["subscription"]["id"]);
|
|
366
|
-
return [2 /*return*/, subscription["subscription"]];
|
|
367
|
-
case 3:
|
|
368
|
-
e_4 = _a.sent();
|
|
369
|
-
throw e_4;
|
|
370
|
-
case 4: return [2 /*return*/];
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
/**
|
|
376
|
-
* Subscribe a channel.
|
|
377
|
-
*
|
|
378
|
-
* @async
|
|
379
|
-
* @function subscibe
|
|
380
|
-
* @param {string} channel - The id of a channel.
|
|
381
|
-
* @param {any} option
|
|
382
|
-
* @returns
|
|
383
|
-
*/
|
|
384
|
-
NCloudChat.prototype.subscribe = function (channel, option) {
|
|
385
|
-
if (option === void 0) { option = null; }
|
|
386
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
387
|
-
var subscription, e_5;
|
|
388
|
-
return __generator(this, function (_a) {
|
|
389
|
-
switch (_a.label) {
|
|
390
|
-
case 0:
|
|
391
|
-
this.inputValidation({ channelId: channel });
|
|
392
|
-
_a.label = 1;
|
|
393
|
-
case 1:
|
|
394
|
-
_a.trys.push([1, 3, , 4]);
|
|
395
|
-
return [4 /*yield*/, createSubscription(channel, JSON.stringify(option))];
|
|
396
|
-
case 2:
|
|
397
|
-
subscription = _a.sent();
|
|
398
|
-
if (subscription["subscription"])
|
|
399
|
-
subscription["subscription"]["id"] = this.ObjectId(subscription["subscription"]["id"]);
|
|
400
|
-
return [2 /*return*/, subscription["subscription"]];
|
|
401
|
-
case 3:
|
|
402
|
-
e_5 = _a.sent();
|
|
403
|
-
throw e_5;
|
|
404
|
-
case 4: return [2 /*return*/];
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
};
|
|
409
|
-
/**
|
|
410
|
-
* Unsubscribe from a channel.
|
|
411
|
-
*
|
|
412
|
-
* @async
|
|
413
|
-
* @function unsubscribe
|
|
414
|
-
* @param {string} channel - The id of a chennel
|
|
415
|
-
* @returns {Promise<any>}
|
|
416
|
-
*/
|
|
417
|
-
NCloudChat.prototype.unsubscribe = function (channel) {
|
|
418
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
419
|
-
var subscription, e_6;
|
|
420
|
-
return __generator(this, function (_a) {
|
|
421
|
-
switch (_a.label) {
|
|
422
|
-
case 0:
|
|
423
|
-
this.inputValidation({ channelId: channel });
|
|
424
|
-
_a.label = 1;
|
|
425
|
-
case 1:
|
|
426
|
-
_a.trys.push([1, 3, , 4]);
|
|
427
|
-
return [4 /*yield*/, deleteSubscription(channel)];
|
|
428
|
-
case 2:
|
|
429
|
-
subscription = _a.sent();
|
|
430
|
-
if (subscription["subscription"])
|
|
431
|
-
subscription["subscription"]["id"] = this.ObjectId(subscription["subscription"]["id"]);
|
|
432
|
-
return [2 /*return*/, subscription["subscription"]];
|
|
433
|
-
case 3:
|
|
434
|
-
e_6 = _a.sent();
|
|
435
|
-
throw e_6;
|
|
436
|
-
case 4: return [2 /*return*/];
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
});
|
|
440
|
-
};
|
|
441
|
-
/**
|
|
442
|
-
* Translate a message from a souce language to a target language.
|
|
443
|
-
*
|
|
444
|
-
* @async
|
|
445
|
-
* @function translateMessage
|
|
446
|
-
* @param {string} channelId - The id of a channel.
|
|
447
|
-
* @param {string} source - A source language.
|
|
448
|
-
* @param {string} target - A target language.
|
|
449
|
-
* @param {string} message - An message to be translated.
|
|
450
|
-
* @returns {Promise<any>}
|
|
451
|
-
*/
|
|
452
|
-
NCloudChat.prototype.translateMessage = function (channelId, source, target, message) {
|
|
453
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
454
|
-
var result, e_7;
|
|
455
|
-
return __generator(this, function (_a) {
|
|
456
|
-
switch (_a.label) {
|
|
457
|
-
case 0:
|
|
458
|
-
this.inputValidation({
|
|
459
|
-
channelId: channelId,
|
|
460
|
-
sourceLanguage: source,
|
|
461
|
-
targetLanguage: target
|
|
462
|
-
});
|
|
463
|
-
_a.label = 1;
|
|
464
|
-
case 1:
|
|
465
|
-
_a.trys.push([1, 3, , 4]);
|
|
466
|
-
return [4 /*yield*/, translate(channelId, source, target, message)];
|
|
467
|
-
case 2:
|
|
468
|
-
result = _a.sent();
|
|
469
|
-
return [2 /*return*/, result["translation"]];
|
|
470
|
-
case 3:
|
|
471
|
-
e_7 = _a.sent();
|
|
472
|
-
if (e_7 instanceof Error) {
|
|
473
|
-
throw Error(e_7.message);
|
|
474
|
-
}
|
|
475
|
-
return [3 /*break*/, 4];
|
|
476
|
-
case 4: return [2 /*return*/];
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
});
|
|
480
|
-
};
|
|
481
|
-
/**
|
|
482
|
-
* Send a message to a channel.
|
|
483
|
-
*
|
|
484
|
-
* @async
|
|
485
|
-
* @function sendMessage
|
|
486
|
-
* @param {string} channel - The id of a channel.
|
|
487
|
-
* @param {any} opt
|
|
488
|
-
* @returns {Promise<any>}
|
|
489
|
-
*/
|
|
490
|
-
NCloudChat.prototype.sendMessage = function (channel, opt) {
|
|
491
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
492
|
-
var data, result, e_8;
|
|
493
|
-
return __generator(this, function (_a) {
|
|
494
|
-
switch (_a.label) {
|
|
495
|
-
case 0:
|
|
496
|
-
this.inputValidation({ channelId: channel, message: opt.message });
|
|
497
|
-
if (!opt.type)
|
|
498
|
-
opt.type = "text";
|
|
499
|
-
_a.label = 1;
|
|
500
|
-
case 1:
|
|
501
|
-
_a.trys.push([1, 3, , 4]);
|
|
502
|
-
data = __assign({ channelId: channel }, opt);
|
|
503
|
-
return [4 /*yield*/, message(data)];
|
|
504
|
-
case 2:
|
|
505
|
-
result = _a.sent();
|
|
506
|
-
return [2 /*return*/, result["message"]];
|
|
507
|
-
case 3:
|
|
508
|
-
e_8 = _a.sent();
|
|
509
|
-
throw e_8;
|
|
510
|
-
case 4: return [2 /*return*/];
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
});
|
|
514
|
-
};
|
|
515
|
-
/**
|
|
516
|
-
* Send an express message to a channel.
|
|
517
|
-
*
|
|
518
|
-
* @async
|
|
519
|
-
* @function sendExpressMessage
|
|
520
|
-
* @param {string} channel - The id of a channel.
|
|
521
|
-
* @param {any} opt
|
|
522
|
-
* @returns {Promise<any>}
|
|
523
|
-
*/
|
|
524
|
-
NCloudChat.prototype.sendExpressMessage = function (channel, opt) {
|
|
525
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
526
|
-
var user, data;
|
|
527
|
-
return __generator(this, function (_a) {
|
|
528
|
-
if (!this.isConnected())
|
|
529
|
-
throw Error("You are not connected.");
|
|
530
|
-
this.inputValidation({ channelId: channel, message: opt.message });
|
|
531
|
-
if (!opt.type)
|
|
532
|
-
opt.type = "text";
|
|
533
|
-
user = CoreManager.get("USER");
|
|
534
|
-
if (!user)
|
|
535
|
-
throw Error('user is null');
|
|
536
|
-
try {
|
|
537
|
-
data = __assign({ channelId: channel, user: user }, opt);
|
|
538
|
-
this.socket.emit("express message", data);
|
|
539
|
-
return [2 /*return*/, data];
|
|
540
|
-
}
|
|
541
|
-
catch (e) {
|
|
542
|
-
throw e;
|
|
543
|
-
}
|
|
544
|
-
return [2 /*return*/];
|
|
545
|
-
});
|
|
546
|
-
});
|
|
547
|
-
};
|
|
548
|
-
/**
|
|
549
|
-
* Send an image to a channel. Only supports png, jpg, jpeg file types.
|
|
550
|
-
*
|
|
551
|
-
* @async
|
|
552
|
-
* @function sendImage
|
|
553
|
-
* @param {string} channelId - The id of a channel.
|
|
554
|
-
* @param {any} file - An image file.
|
|
555
|
-
* @returns {Promise<any>}
|
|
556
|
-
*/
|
|
557
|
-
NCloudChat.prototype.sendImage = function (channelId, file) {
|
|
558
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
559
|
-
var result;
|
|
560
|
-
return __generator(this, function (_a) {
|
|
561
|
-
switch (_a.label) {
|
|
562
|
-
case 0:
|
|
563
|
-
this.inputValidation({ channelId: channelId });
|
|
564
|
-
return [4 /*yield*/, upload(channelId, file)];
|
|
565
|
-
case 1:
|
|
566
|
-
result = _a.sent();
|
|
567
|
-
if (!result.status)
|
|
568
|
-
throw Error(result.message);
|
|
569
|
-
return [2 /*return*/, result];
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
|
-
});
|
|
573
|
-
};
|
|
574
|
-
/**
|
|
575
|
-
* Update a message.
|
|
576
|
-
*
|
|
577
|
-
* @todo
|
|
578
|
-
* @async
|
|
579
|
-
* @function updateMessage
|
|
580
|
-
* @param {string} channel
|
|
581
|
-
* @param {string} message_id
|
|
582
|
-
* @param {string} message
|
|
583
|
-
*/
|
|
584
|
-
NCloudChat.prototype.updateMessage = function (channel, message_id, message) {
|
|
585
|
-
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
586
|
-
return [2 /*return*/];
|
|
587
|
-
}); });
|
|
588
|
-
};
|
|
589
|
-
/**
|
|
590
|
-
* Delete a message.
|
|
591
|
-
* @async
|
|
592
|
-
* @function deleteMessage
|
|
593
|
-
* @param {string} channel
|
|
594
|
-
* @param {string} message_id
|
|
595
|
-
*/
|
|
596
|
-
NCloudChat.prototype.deleteMessage = function (channel, message_id) {
|
|
597
|
-
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
598
|
-
return [2 /*return*/];
|
|
599
|
-
}); });
|
|
600
|
-
};
|
|
601
|
-
/**
|
|
602
|
-
* Disconnect from a socket.
|
|
603
|
-
*
|
|
604
|
-
* @async
|
|
605
|
-
* @function disconnect
|
|
606
|
-
* @returns
|
|
607
|
-
*/
|
|
608
|
-
NCloudChat.prototype.disconnect = function () {
|
|
609
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
610
|
-
return __generator(this, function (_a) {
|
|
611
|
-
if (!this.isConnected())
|
|
612
|
-
return [2 /*return*/];
|
|
613
|
-
this.socket.disconnect();
|
|
614
|
-
CoreManager.set("TOKEN", "");
|
|
615
|
-
return [2 /*return*/];
|
|
616
|
-
});
|
|
617
|
-
});
|
|
618
|
-
};
|
|
619
|
-
/**
|
|
620
|
-
* Check if a client is connected to a socket.
|
|
621
|
-
*
|
|
622
|
-
* @function isConnected
|
|
623
|
-
* @returns {boolean}
|
|
624
|
-
*/
|
|
625
|
-
NCloudChat.prototype.isConnected = function () {
|
|
626
|
-
var token = CoreManager.get("TOKEN");
|
|
627
|
-
if (token)
|
|
628
|
-
return true;
|
|
629
|
-
return false;
|
|
630
|
-
};
|
|
631
|
-
NCloudChat.prototype.isSocketConnected = function () {
|
|
632
|
-
return this.connected ? true : false;
|
|
633
|
-
};
|
|
634
|
-
/**
|
|
635
|
-
* Bind fn event handlers.
|
|
636
|
-
*
|
|
637
|
-
* @async
|
|
638
|
-
* @function bind
|
|
639
|
-
* @param {string} id
|
|
640
|
-
* @param {any} fn
|
|
641
|
-
*/
|
|
642
|
-
NCloudChat.prototype.bind = function (id, fn) {
|
|
643
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
644
|
-
return __generator(this, function (_a) {
|
|
645
|
-
this.dp.off(id);
|
|
646
|
-
this.dp.on(id, fn);
|
|
647
|
-
return [2 /*return*/];
|
|
648
|
-
});
|
|
649
|
-
});
|
|
650
|
-
};
|
|
651
|
-
/**
|
|
652
|
-
* Unbind fn event handlers.
|
|
653
|
-
*
|
|
654
|
-
* @async
|
|
655
|
-
* @function unbind
|
|
656
|
-
* @param {string} id
|
|
657
|
-
* @param {any} fn
|
|
658
|
-
*/
|
|
659
|
-
NCloudChat.prototype.unbind = function (id) {
|
|
660
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
661
|
-
return __generator(this, function (_a) {
|
|
662
|
-
this.dp.off(id);
|
|
663
|
-
return [2 /*return*/];
|
|
664
|
-
});
|
|
665
|
-
});
|
|
666
|
-
};
|
|
667
|
-
/**
|
|
668
|
-
* Unbind all event handlers.
|
|
669
|
-
* @param id
|
|
670
|
-
*/
|
|
671
|
-
NCloudChat.prototype.unbindall = function (id) {
|
|
672
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
673
|
-
return __generator(this, function (_a) {
|
|
674
|
-
this.dp.offall(id);
|
|
675
|
-
return [2 /*return*/];
|
|
676
|
-
});
|
|
677
|
-
});
|
|
678
|
-
};
|
|
679
|
-
/**
|
|
680
|
-
* Decodes a base-64 encoded string.
|
|
681
|
-
*
|
|
682
|
-
* @function ObjectId
|
|
683
|
-
* @param {string} id - An encoded string to be decoded.
|
|
684
|
-
* @returns {string} decoded string.
|
|
685
|
-
*/
|
|
686
|
-
NCloudChat.prototype.ObjectId = function (id) {
|
|
687
|
-
if (!id)
|
|
688
|
-
return "";
|
|
689
|
-
return atob(id).split(":")[1];
|
|
690
|
-
};
|
|
691
|
-
/**
|
|
692
|
-
* Get current friends list of all status.
|
|
693
|
-
*
|
|
694
|
-
* @async
|
|
695
|
-
* @function getFriendships
|
|
696
|
-
* @param {string} filter - Field value for filter.
|
|
697
|
-
* @param {string} sort - Field value for sorting.
|
|
698
|
-
* @param {string} option - Optional option: ex) offset, per_page.
|
|
699
|
-
* @returns {Promise<any>}
|
|
700
|
-
*/
|
|
701
|
-
NCloudChat.prototype.getFriendships = function (filter, sort, option) {
|
|
702
|
-
if (sort === void 0) { sort = {}; }
|
|
703
|
-
if (option === void 0) { option = {}; }
|
|
704
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
705
|
-
var entries, friends, e_9;
|
|
706
|
-
var _this = this;
|
|
707
|
-
return __generator(this, function (_a) {
|
|
708
|
-
switch (_a.label) {
|
|
709
|
-
case 0:
|
|
710
|
-
this.inputValidation({});
|
|
711
|
-
_a.label = 1;
|
|
712
|
-
case 1:
|
|
713
|
-
_a.trys.push([1, 3, , 4]);
|
|
714
|
-
return [4 /*yield*/, getFriendships(JSON.stringify(filter), JSON.stringify(sort), JSON.stringify(option))];
|
|
715
|
-
case 2:
|
|
716
|
-
entries = _a.sent();
|
|
717
|
-
if (entries) {
|
|
718
|
-
friends = entries["edges"].map(function (item) {
|
|
719
|
-
item.node.friend.id = _this.ObjectId(item.node.friend.id);
|
|
720
|
-
item.node.user.id = _this.ObjectId(item.node.user.id);
|
|
721
|
-
return __assign(__assign({}, item.node), { id: item.node.id });
|
|
722
|
-
});
|
|
723
|
-
return [2 /*return*/, friends];
|
|
724
|
-
}
|
|
725
|
-
return [2 /*return*/, entries["edges"]];
|
|
726
|
-
case 3:
|
|
727
|
-
e_9 = _a.sent();
|
|
728
|
-
throw e_9;
|
|
729
|
-
case 4: return [2 /*return*/];
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
});
|
|
733
|
-
};
|
|
734
|
-
/**
|
|
735
|
-
* Get member blocks.
|
|
736
|
-
*
|
|
737
|
-
* @async
|
|
738
|
-
* @function getBannedUsers
|
|
739
|
-
* @param {string} filter - Field value for filter.
|
|
740
|
-
* @param {string} sort - Field value for sorting.
|
|
741
|
-
* @param {string} option - Optional option: ex) offset, per_page.
|
|
742
|
-
* @returns {Promise<any>}
|
|
743
|
-
*/
|
|
744
|
-
NCloudChat.prototype.getBannedUsers = function (filter, sort, option) {
|
|
745
|
-
if (sort === void 0) { sort = {}; }
|
|
746
|
-
if (option === void 0) { option = {}; }
|
|
747
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
748
|
-
var entries, members, e_10;
|
|
749
|
-
var _this = this;
|
|
750
|
-
return __generator(this, function (_a) {
|
|
751
|
-
switch (_a.label) {
|
|
752
|
-
case 0:
|
|
753
|
-
this.inputValidation({});
|
|
754
|
-
_a.label = 1;
|
|
755
|
-
case 1:
|
|
756
|
-
_a.trys.push([1, 3, , 4]);
|
|
757
|
-
return [4 /*yield*/, getMemberBlocks(JSON.stringify(filter), JSON.stringify(sort), JSON.stringify(option))];
|
|
758
|
-
case 2:
|
|
759
|
-
entries = _a.sent();
|
|
760
|
-
if (entries["edges"]) {
|
|
761
|
-
members = entries["edges"].map(function (item) {
|
|
762
|
-
return __assign(__assign({}, item.node), { id: _this.ObjectId(item.node.id) });
|
|
763
|
-
});
|
|
764
|
-
return [2 /*return*/, members];
|
|
765
|
-
}
|
|
766
|
-
return [2 /*return*/, entries["edges"]];
|
|
767
|
-
case 3:
|
|
768
|
-
e_10 = _a.sent();
|
|
769
|
-
throw e_10;
|
|
770
|
-
case 4: return [2 /*return*/];
|
|
771
|
-
}
|
|
772
|
-
});
|
|
773
|
-
});
|
|
774
|
-
};
|
|
775
|
-
/**
|
|
776
|
-
* Get information data of the member.
|
|
777
|
-
*
|
|
778
|
-
* @async
|
|
779
|
-
* @function getUsers
|
|
780
|
-
* @param {string} filter - Field value for filter.
|
|
781
|
-
* @param {string} sort - Field value for sorting.
|
|
782
|
-
* @param {string} option - Optional option: ex) offset, per_page.
|
|
783
|
-
* @returns {Promise<any>}
|
|
784
|
-
*/
|
|
785
|
-
NCloudChat.prototype.getUsers = function (filter, sort, option) {
|
|
786
|
-
if (sort === void 0) { sort = {}; }
|
|
787
|
-
if (option === void 0) { option = {}; }
|
|
788
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
789
|
-
var entries, members, e_11;
|
|
790
|
-
var _this = this;
|
|
791
|
-
return __generator(this, function (_a) {
|
|
792
|
-
switch (_a.label) {
|
|
793
|
-
case 0:
|
|
794
|
-
this.inputValidation({});
|
|
795
|
-
_a.label = 1;
|
|
796
|
-
case 1:
|
|
797
|
-
_a.trys.push([1, 3, , 4]);
|
|
798
|
-
return [4 /*yield*/, getMembers(JSON.stringify(filter), JSON.stringify(sort), JSON.stringify(option))];
|
|
799
|
-
case 2:
|
|
800
|
-
entries = _a.sent();
|
|
801
|
-
if (entries) {
|
|
802
|
-
members = entries['edges'].map(function (item) {
|
|
803
|
-
return __assign(__assign({}, item.node), { id: _this.ObjectId(item.node.id) });
|
|
804
|
-
});
|
|
805
|
-
return [2 /*return*/, members];
|
|
806
|
-
}
|
|
807
|
-
return [3 /*break*/, 4];
|
|
808
|
-
case 3:
|
|
809
|
-
e_11 = _a.sent();
|
|
810
|
-
throw e_11;
|
|
811
|
-
case 4: return [2 /*return*/];
|
|
812
|
-
}
|
|
813
|
-
});
|
|
814
|
-
});
|
|
815
|
-
};
|
|
816
|
-
/**
|
|
817
|
-
* Request a friendship to a user.
|
|
818
|
-
*
|
|
819
|
-
* @async
|
|
820
|
-
* @function requestFriend
|
|
821
|
-
* @param {string} friendId - An id of the friend to request.
|
|
822
|
-
* @returns {Promise<any>}
|
|
823
|
-
*/
|
|
824
|
-
NCloudChat.prototype.requestFriend = function (friendId) {
|
|
825
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
826
|
-
var result, e_12;
|
|
827
|
-
return __generator(this, function (_a) {
|
|
828
|
-
switch (_a.label) {
|
|
829
|
-
case 0:
|
|
830
|
-
this.inputValidation({ friendId: friendId });
|
|
831
|
-
_a.label = 1;
|
|
832
|
-
case 1:
|
|
833
|
-
_a.trys.push([1, 3, , 4]);
|
|
834
|
-
return [4 /*yield*/, requestFriend(friendId)];
|
|
835
|
-
case 2:
|
|
836
|
-
result = _a.sent();
|
|
837
|
-
if (result["friendship"]) {
|
|
838
|
-
result["friendship"]["user"]["id"] = this.ObjectId(result["friendship"]["user"]["id"]);
|
|
839
|
-
result["friendship"]["friend"]["id"] = this.ObjectId(result["friendship"]["friend"]["id"]);
|
|
840
|
-
}
|
|
841
|
-
return [2 /*return*/, result["friendship"]];
|
|
842
|
-
case 3:
|
|
843
|
-
e_12 = _a.sent();
|
|
844
|
-
throw e_12;
|
|
845
|
-
case 4: return [2 /*return*/];
|
|
846
|
-
}
|
|
847
|
-
});
|
|
848
|
-
});
|
|
849
|
-
};
|
|
850
|
-
/**
|
|
851
|
-
* Accept a friends request.
|
|
852
|
-
*
|
|
853
|
-
* @async
|
|
854
|
-
* @function acceptFriend
|
|
855
|
-
* @param {string} friendId - The id of the friend to accept the request.
|
|
856
|
-
* @returns {Promise<any>}
|
|
857
|
-
*/
|
|
858
|
-
NCloudChat.prototype.acceptFriend = function (friendId) {
|
|
859
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
860
|
-
var result, e_13;
|
|
861
|
-
return __generator(this, function (_a) {
|
|
862
|
-
switch (_a.label) {
|
|
863
|
-
case 0:
|
|
864
|
-
this.inputValidation({ friendId: friendId });
|
|
865
|
-
_a.label = 1;
|
|
866
|
-
case 1:
|
|
867
|
-
_a.trys.push([1, 3, , 4]);
|
|
868
|
-
return [4 /*yield*/, acceptFriend(friendId)];
|
|
869
|
-
case 2:
|
|
870
|
-
result = _a.sent();
|
|
871
|
-
if (result["friendship"]) {
|
|
872
|
-
result["friendship"]["user"]["id"] = this.ObjectId(result["friendship"]["user"]["id"]);
|
|
873
|
-
result["friendship"]["friend"]["id"] = this.ObjectId(result["friendship"]["friend"]["id"]);
|
|
874
|
-
}
|
|
875
|
-
return [2 /*return*/, result["friendship"]];
|
|
876
|
-
case 3:
|
|
877
|
-
e_13 = _a.sent();
|
|
878
|
-
throw e_13;
|
|
879
|
-
case 4: return [2 /*return*/];
|
|
880
|
-
}
|
|
881
|
-
});
|
|
882
|
-
});
|
|
883
|
-
};
|
|
884
|
-
/**
|
|
885
|
-
* Reject a friend request.
|
|
886
|
-
*
|
|
887
|
-
* @async
|
|
888
|
-
* @function rejectFriend
|
|
889
|
-
* @param {string} friendId - An id of the friend to be rejected.
|
|
890
|
-
* @returns {Promise<any>}
|
|
891
|
-
*/
|
|
892
|
-
NCloudChat.prototype.rejectFriend = function (friendId) {
|
|
893
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
894
|
-
var result, e_14;
|
|
895
|
-
return __generator(this, function (_a) {
|
|
896
|
-
switch (_a.label) {
|
|
897
|
-
case 0:
|
|
898
|
-
this.inputValidation({ friendId: friendId });
|
|
899
|
-
_a.label = 1;
|
|
900
|
-
case 1:
|
|
901
|
-
_a.trys.push([1, 3, , 4]);
|
|
902
|
-
return [4 /*yield*/, rejectFriend(friendId)];
|
|
903
|
-
case 2:
|
|
904
|
-
result = _a.sent();
|
|
905
|
-
if (result["friendship"]) {
|
|
906
|
-
result["friendship"]["user"]["id"] = this.ObjectId(result["friendship"]["user"]["id"]);
|
|
907
|
-
result["friendship"]["friend"]["id"] = this.ObjectId(result["friendship"]["friend"]["id"]);
|
|
908
|
-
}
|
|
909
|
-
return [2 /*return*/, result["friendship"]];
|
|
910
|
-
case 3:
|
|
911
|
-
e_14 = _a.sent();
|
|
912
|
-
throw e_14;
|
|
913
|
-
case 4: return [2 /*return*/];
|
|
914
|
-
}
|
|
915
|
-
});
|
|
916
|
-
});
|
|
917
|
-
};
|
|
918
|
-
/**
|
|
919
|
-
* Remove a friend.
|
|
920
|
-
*
|
|
921
|
-
* @async
|
|
922
|
-
* @function removeFriend
|
|
923
|
-
* @param {string} friendId - An id of the friend to be removed.
|
|
924
|
-
* @returns {Promise<any>}
|
|
925
|
-
*/
|
|
926
|
-
NCloudChat.prototype.removeFriend = function (friendId) {
|
|
927
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
928
|
-
var result, e_15;
|
|
929
|
-
return __generator(this, function (_a) {
|
|
930
|
-
switch (_a.label) {
|
|
931
|
-
case 0:
|
|
932
|
-
this.inputValidation({ friendId: friendId });
|
|
933
|
-
_a.label = 1;
|
|
934
|
-
case 1:
|
|
935
|
-
_a.trys.push([1, 3, , 4]);
|
|
936
|
-
return [4 /*yield*/, removeFriend(friendId)];
|
|
937
|
-
case 2:
|
|
938
|
-
result = _a.sent();
|
|
939
|
-
if (result["friendship"]) {
|
|
940
|
-
result["friendship"]["user"]["id"] = this.ObjectId(result["friendship"]["user"]["id"]);
|
|
941
|
-
result["friendship"]["friend"]["id"] = this.ObjectId(result["friendship"]["friend"]["id"]);
|
|
942
|
-
}
|
|
943
|
-
return [2 /*return*/, result["friendship"]];
|
|
944
|
-
case 3:
|
|
945
|
-
e_15 = _a.sent();
|
|
946
|
-
throw e_15;
|
|
947
|
-
case 4: return [2 /*return*/];
|
|
948
|
-
}
|
|
949
|
-
});
|
|
950
|
-
});
|
|
951
|
-
};
|
|
952
|
-
/**
|
|
953
|
-
* Get a count of unread messages of a channel.
|
|
954
|
-
*
|
|
955
|
-
* @async
|
|
956
|
-
* @function countUnread
|
|
957
|
-
* @param {string} channelId - The id of a channel.
|
|
958
|
-
* @returns {Promise<any>}
|
|
959
|
-
*/
|
|
960
|
-
NCloudChat.prototype.countUnread = function (channelId) {
|
|
961
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
962
|
-
var e_16;
|
|
963
|
-
return __generator(this, function (_a) {
|
|
964
|
-
switch (_a.label) {
|
|
965
|
-
case 0:
|
|
966
|
-
this.inputValidation({ channelId: channelId });
|
|
967
|
-
_a.label = 1;
|
|
968
|
-
case 1:
|
|
969
|
-
_a.trys.push([1, 3, , 4]);
|
|
970
|
-
return [4 /*yield*/, unreadCount(channelId)];
|
|
971
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
972
|
-
case 3:
|
|
973
|
-
e_16 = _a.sent();
|
|
974
|
-
throw e_16;
|
|
975
|
-
case 4: return [2 /*return*/];
|
|
976
|
-
}
|
|
977
|
-
});
|
|
978
|
-
});
|
|
979
|
-
};
|
|
980
|
-
/**
|
|
981
|
-
* Get subscription data of the user.
|
|
982
|
-
*
|
|
983
|
-
* @async
|
|
984
|
-
* @function getSubscription
|
|
985
|
-
* @param {string} channelId - The id of a channel.
|
|
986
|
-
* @param {string} id
|
|
987
|
-
* @returns {Promise<any>}
|
|
988
|
-
*/
|
|
989
|
-
NCloudChat.prototype.getSubscription = function (channelId, id) {
|
|
990
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
991
|
-
var subscription, e_17;
|
|
992
|
-
return __generator(this, function (_a) {
|
|
993
|
-
switch (_a.label) {
|
|
994
|
-
case 0:
|
|
995
|
-
this.inputValidation({ channelId: channelId, subscriptionId: id });
|
|
996
|
-
_a.label = 1;
|
|
997
|
-
case 1:
|
|
998
|
-
_a.trys.push([1, 3, , 4]);
|
|
999
|
-
return [4 /*yield*/, getSubscription(channelId, id)];
|
|
1000
|
-
case 2:
|
|
1001
|
-
subscription = _a.sent();
|
|
1002
|
-
if (subscription)
|
|
1003
|
-
subscription["id"] = this.ObjectId(subscription["id"]);
|
|
1004
|
-
return [2 /*return*/, subscription];
|
|
1005
|
-
case 3:
|
|
1006
|
-
e_17 = _a.sent();
|
|
1007
|
-
throw e_17;
|
|
1008
|
-
case 4: return [2 /*return*/];
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
});
|
|
1012
|
-
};
|
|
1013
|
-
/**
|
|
1014
|
-
* Get data of a single channel from the endpoint.
|
|
1015
|
-
*
|
|
1016
|
-
* @async
|
|
1017
|
-
* @function getChannel
|
|
1018
|
-
* @param {string} channelId - An id of the channel.
|
|
1019
|
-
* @returns {Promise<any>} The data of the channel.
|
|
1020
|
-
*/
|
|
1021
|
-
NCloudChat.prototype.getChannel = function (channelId) {
|
|
1022
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1023
|
-
var result, e_18;
|
|
1024
|
-
return __generator(this, function (_a) {
|
|
1025
|
-
switch (_a.label) {
|
|
1026
|
-
case 0:
|
|
1027
|
-
this.inputValidation({ channelId: channelId });
|
|
1028
|
-
_a.label = 1;
|
|
1029
|
-
case 1:
|
|
1030
|
-
_a.trys.push([1, 3, , 4]);
|
|
1031
|
-
return [4 /*yield*/, getChannel(channelId)];
|
|
1032
|
-
case 2:
|
|
1033
|
-
result = _a.sent();
|
|
1034
|
-
if (result) {
|
|
1035
|
-
result.id = this.ObjectId(result.id);
|
|
1036
|
-
result["user_id"]["id"] = this.ObjectId(result["user_id"]["id"]);
|
|
1037
|
-
}
|
|
1038
|
-
return [2 /*return*/, result];
|
|
1039
|
-
case 3:
|
|
1040
|
-
e_18 = _a.sent();
|
|
1041
|
-
throw e_18;
|
|
1042
|
-
case 4: return [2 /*return*/];
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
1045
|
-
});
|
|
1046
|
-
};
|
|
1047
|
-
/**
|
|
1048
|
-
* Get data of multiple channels.
|
|
1049
|
-
*
|
|
1050
|
-
* @async
|
|
1051
|
-
* @function getChannels
|
|
1052
|
-
* @param {string} filter - Field value for filter.
|
|
1053
|
-
* @param {string} sort - Field value for sorting.
|
|
1054
|
-
* @param {string} option - Optional option: ex) offset, per_page.
|
|
1055
|
-
* @returns {Promise<any[]>} An array of data of all channels.
|
|
1056
|
-
*/
|
|
1057
|
-
NCloudChat.prototype.getChannels = function (filter, sort, option) {
|
|
1058
|
-
if (sort === void 0) { sort = {}; }
|
|
1059
|
-
if (option === void 0) { option = {}; }
|
|
1060
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1061
|
-
var entries, channels, e_19;
|
|
1062
|
-
var _this = this;
|
|
1063
|
-
return __generator(this, function (_a) {
|
|
1064
|
-
switch (_a.label) {
|
|
1065
|
-
case 0:
|
|
1066
|
-
this.inputValidation({});
|
|
1067
|
-
_a.label = 1;
|
|
1068
|
-
case 1:
|
|
1069
|
-
_a.trys.push([1, 3, , 4]);
|
|
1070
|
-
return [4 /*yield*/, getChannels(JSON.stringify(filter), JSON.stringify(sort), JSON.stringify(option))];
|
|
1071
|
-
case 2:
|
|
1072
|
-
entries = _a.sent();
|
|
1073
|
-
if (entries["edges"]) {
|
|
1074
|
-
channels = entries["edges"].map(function (item) {
|
|
1075
|
-
item.node.user_id.id = _this.ObjectId(item.node.user_id.id);
|
|
1076
|
-
return __assign(__assign({}, item.node), { id: _this.ObjectId(item.node.id) });
|
|
1077
|
-
});
|
|
1078
|
-
return [2 /*return*/, channels];
|
|
1079
|
-
}
|
|
1080
|
-
return [2 /*return*/, entries["edges"]];
|
|
1081
|
-
case 3:
|
|
1082
|
-
e_19 = _a.sent();
|
|
1083
|
-
throw e_19;
|
|
1084
|
-
case 4: return [2 /*return*/];
|
|
1085
|
-
}
|
|
1086
|
-
});
|
|
1087
|
-
});
|
|
1088
|
-
};
|
|
1089
|
-
/**
|
|
1090
|
-
* @async
|
|
1091
|
-
* @function getMessage
|
|
1092
|
-
* @param {string} channelId - The id of a channel.
|
|
1093
|
-
* @param {string} messageId - The id of a message.
|
|
1094
|
-
* @returns {Promise<any>}
|
|
1095
|
-
*/
|
|
1096
|
-
NCloudChat.prototype.getMessage = function (channelId, messageId) {
|
|
1097
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1098
|
-
var entry, e_20;
|
|
1099
|
-
return __generator(this, function (_a) {
|
|
1100
|
-
switch (_a.label) {
|
|
1101
|
-
case 0:
|
|
1102
|
-
this.inputValidation({ channelId: channelId, messageId: messageId });
|
|
1103
|
-
_a.label = 1;
|
|
1104
|
-
case 1:
|
|
1105
|
-
_a.trys.push([1, 3, , 4]);
|
|
1106
|
-
return [4 /*yield*/, getMessage(channelId, messageId)];
|
|
1107
|
-
case 2:
|
|
1108
|
-
entry = _a.sent();
|
|
1109
|
-
if (entry) {
|
|
1110
|
-
entry.id = this.ObjectId(entry.id);
|
|
1111
|
-
return [2 /*return*/, entry];
|
|
1112
|
-
}
|
|
1113
|
-
return [2 /*return*/, entry];
|
|
1114
|
-
case 3:
|
|
1115
|
-
e_20 = _a.sent();
|
|
1116
|
-
throw e_20;
|
|
1117
|
-
case 4: return [2 /*return*/];
|
|
1118
|
-
}
|
|
1119
|
-
});
|
|
1120
|
-
});
|
|
1121
|
-
};
|
|
1122
|
-
/**
|
|
1123
|
-
* Get data of the all messages.
|
|
1124
|
-
*
|
|
1125
|
-
* @async
|
|
1126
|
-
* @function getMessages
|
|
1127
|
-
* @param {string} filter - Field value for filter.
|
|
1128
|
-
* @param {string} sort - Field value for sorting.
|
|
1129
|
-
* @param {string} option - Optional option: ex) offset, per_page.
|
|
1130
|
-
* @returns {Promise<any>}
|
|
1131
|
-
*/
|
|
1132
|
-
NCloudChat.prototype.getMessages = function (filter, sort, option) {
|
|
1133
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1134
|
-
var entries, messages, e_21;
|
|
1135
|
-
var _this = this;
|
|
1136
|
-
return __generator(this, function (_a) {
|
|
1137
|
-
switch (_a.label) {
|
|
1138
|
-
case 0:
|
|
1139
|
-
this.inputValidation({});
|
|
1140
|
-
_a.label = 1;
|
|
1141
|
-
case 1:
|
|
1142
|
-
_a.trys.push([1, 3, , 4]);
|
|
1143
|
-
return [4 /*yield*/, getMessages(JSON.stringify(filter), JSON.stringify(sort), JSON.stringify(option))];
|
|
1144
|
-
case 2:
|
|
1145
|
-
entries = _a.sent();
|
|
1146
|
-
if (entries["edges"]) {
|
|
1147
|
-
messages = entries["edges"].map(function (item) {
|
|
1148
|
-
return __assign(__assign({}, item.node), { id: _this.ObjectId(item.node.id) });
|
|
1149
|
-
});
|
|
1150
|
-
return [2 /*return*/, messages];
|
|
1151
|
-
}
|
|
1152
|
-
return [2 /*return*/, entries["edges"]];
|
|
1153
|
-
case 3:
|
|
1154
|
-
e_21 = _a.sent();
|
|
1155
|
-
throw e_21;
|
|
1156
|
-
case 4: return [2 /*return*/];
|
|
1157
|
-
}
|
|
1158
|
-
});
|
|
1159
|
-
});
|
|
1160
|
-
};
|
|
1161
|
-
/**
|
|
1162
|
-
* Get a list of subscibed member of the channel.
|
|
1163
|
-
* @param {string} filter - Field value for filter.
|
|
1164
|
-
* @param {string} sort - Field value for sorting.
|
|
1165
|
-
* @param {string} option - Optional option: ex) offset, per_page.
|
|
1166
|
-
* @returns {Promise<any>}
|
|
1167
|
-
*/
|
|
1168
|
-
NCloudChat.prototype.getSubscriptions = function (filter, sort, option) {
|
|
1169
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1170
|
-
var entries, subscribes, e_22;
|
|
1171
|
-
var _this = this;
|
|
1172
|
-
return __generator(this, function (_a) {
|
|
1173
|
-
switch (_a.label) {
|
|
1174
|
-
case 0:
|
|
1175
|
-
this.inputValidation({});
|
|
1176
|
-
_a.label = 1;
|
|
1177
|
-
case 1:
|
|
1178
|
-
_a.trys.push([1, 3, , 4]);
|
|
1179
|
-
return [4 /*yield*/, getSubscriptions(JSON.stringify(filter), JSON.stringify(sort), JSON.stringify(option))];
|
|
1180
|
-
case 2:
|
|
1181
|
-
entries = _a.sent();
|
|
1182
|
-
if (entries["edges"]) {
|
|
1183
|
-
subscribes = entries["edges"].map(function (item) {
|
|
1184
|
-
return __assign(__assign({}, item.node), { id: _this.ObjectId(item.node.id) });
|
|
1185
|
-
});
|
|
1186
|
-
return [2 /*return*/, subscribes];
|
|
1187
|
-
}
|
|
1188
|
-
return [2 /*return*/, entries["edges"]];
|
|
1189
|
-
case 3:
|
|
1190
|
-
e_22 = _a.sent();
|
|
1191
|
-
throw e_22;
|
|
1192
|
-
case 4: return [2 /*return*/];
|
|
1193
|
-
}
|
|
1194
|
-
});
|
|
1195
|
-
});
|
|
1196
|
-
};
|
|
1197
|
-
/**
|
|
1198
|
-
* Create a new channel.
|
|
1199
|
-
*
|
|
1200
|
-
* @async
|
|
1201
|
-
* @function createChannel
|
|
1202
|
-
* @param {ChannelInput} channel - Configuration options of the new channel.
|
|
1203
|
-
* @returns {Promise<any>} The data of the newly created channel.
|
|
1204
|
-
*/
|
|
1205
|
-
NCloudChat.prototype.createChannel = function (channel) {
|
|
1206
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1207
|
-
var result, e_23;
|
|
1208
|
-
return __generator(this, function (_a) {
|
|
1209
|
-
switch (_a.label) {
|
|
1210
|
-
case 0:
|
|
1211
|
-
this.inputValidation({
|
|
1212
|
-
channelType: channel.type,
|
|
1213
|
-
channelName: channel.name
|
|
1214
|
-
});
|
|
1215
|
-
_a.label = 1;
|
|
1216
|
-
case 1:
|
|
1217
|
-
_a.trys.push([1, 3, , 4]);
|
|
1218
|
-
return [4 /*yield*/, createChannel(channel)];
|
|
1219
|
-
case 2:
|
|
1220
|
-
result = _a.sent();
|
|
1221
|
-
if (result["channel"]) {
|
|
1222
|
-
result["channel"]["id"] = this.ObjectId(result["channel"]["id"]);
|
|
1223
|
-
result["channel"]["user_id"]["id"] = this.ObjectId(result["channel"]["user_id"]["id"]);
|
|
1224
|
-
}
|
|
1225
|
-
return [2 /*return*/, result["channel"]];
|
|
1226
|
-
case 3:
|
|
1227
|
-
e_23 = _a.sent();
|
|
1228
|
-
throw e_23;
|
|
1229
|
-
case 4: return [2 /*return*/];
|
|
1230
|
-
}
|
|
1231
|
-
});
|
|
1232
|
-
});
|
|
1233
|
-
};
|
|
1234
|
-
/**
|
|
1235
|
-
* Update channel options.
|
|
1236
|
-
*
|
|
1237
|
-
* @async
|
|
1238
|
-
* @function updateChannel
|
|
1239
|
-
* @param {string} channelId - An id of the channel.
|
|
1240
|
-
* @param {ChannelInput} channel - New options of the channel.
|
|
1241
|
-
* @returns {Promise<any>} The data of the updated channel.
|
|
1242
|
-
*/
|
|
1243
|
-
NCloudChat.prototype.updateChannel = function (channelId, channel) {
|
|
1244
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1245
|
-
var result, e_24;
|
|
1246
|
-
return __generator(this, function (_a) {
|
|
1247
|
-
switch (_a.label) {
|
|
1248
|
-
case 0:
|
|
1249
|
-
this.inputValidation({
|
|
1250
|
-
channelId: channelId
|
|
1251
|
-
});
|
|
1252
|
-
if (!channel.name)
|
|
1253
|
-
throw Error("You need at least a channel name or a type.");
|
|
1254
|
-
_a.label = 1;
|
|
1255
|
-
case 1:
|
|
1256
|
-
_a.trys.push([1, 3, , 4]);
|
|
1257
|
-
return [4 /*yield*/, updateChannel(channelId, channel)];
|
|
1258
|
-
case 2:
|
|
1259
|
-
result = _a.sent();
|
|
1260
|
-
if (result["channel"]) {
|
|
1261
|
-
result["channel"]["id"] = this.ObjectId(result["channel"]["id"]);
|
|
1262
|
-
result["channel"]["user_id"]["id"] = this.ObjectId(result["channel"]["user_id"]["id"]);
|
|
1263
|
-
}
|
|
1264
|
-
return [2 /*return*/, result["channel"]];
|
|
1265
|
-
case 3:
|
|
1266
|
-
e_24 = _a.sent();
|
|
1267
|
-
throw e_24;
|
|
1268
|
-
case 4: return [2 /*return*/];
|
|
1269
|
-
}
|
|
1270
|
-
});
|
|
1271
|
-
});
|
|
1272
|
-
};
|
|
1273
|
-
/**
|
|
1274
|
-
* Delete a channel.
|
|
1275
|
-
*
|
|
1276
|
-
* @async
|
|
1277
|
-
* @function deleteChannel
|
|
1278
|
-
* @param {string} channelId - An channel id.
|
|
1279
|
-
* @returns {Promise<any>}
|
|
1280
|
-
*/
|
|
1281
|
-
NCloudChat.prototype.deleteChannel = function (channelId) {
|
|
1282
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1283
|
-
var result, e_25;
|
|
1284
|
-
return __generator(this, function (_a) {
|
|
1285
|
-
switch (_a.label) {
|
|
1286
|
-
case 0:
|
|
1287
|
-
this.inputValidation({ channelId: channelId });
|
|
1288
|
-
_a.label = 1;
|
|
1289
|
-
case 1:
|
|
1290
|
-
_a.trys.push([1, 3, , 4]);
|
|
1291
|
-
return [4 /*yield*/, deleteChannel(channelId)];
|
|
1292
|
-
case 2:
|
|
1293
|
-
result = _a.sent();
|
|
1294
|
-
if (result["channel"]) {
|
|
1295
|
-
result["channel"]["id"] = this.ObjectId(result["channel"]["id"]);
|
|
1296
|
-
result["channel"]["user_id"]["id"] = this.ObjectId(result["channel"]["user_id"]["id"]);
|
|
1297
|
-
}
|
|
1298
|
-
return [2 /*return*/, result["channel"]];
|
|
1299
|
-
case 3:
|
|
1300
|
-
e_25 = _a.sent();
|
|
1301
|
-
throw e_25;
|
|
1302
|
-
case 4: return [2 /*return*/];
|
|
1303
|
-
}
|
|
1304
|
-
});
|
|
1305
|
-
});
|
|
1306
|
-
};
|
|
1307
|
-
/**
|
|
1308
|
-
* Update a subscription information, such as marking message read.
|
|
1309
|
-
*
|
|
1310
|
-
* @async
|
|
1311
|
-
* @function markRead
|
|
1312
|
-
* @param {string} channelId - The id of a channel.
|
|
1313
|
-
* @param {MarkInput} mark
|
|
1314
|
-
* @param {string} option
|
|
1315
|
-
* @returns {Promise<any>}
|
|
1316
|
-
*/
|
|
1317
|
-
NCloudChat.prototype.markRead = function (channelId, mark, option) {
|
|
1318
|
-
if (option === void 0) { option = null; }
|
|
1319
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1320
|
-
var result, e_26;
|
|
1321
|
-
return __generator(this, function (_a) {
|
|
1322
|
-
switch (_a.label) {
|
|
1323
|
-
case 0:
|
|
1324
|
-
this.inputValidation({
|
|
1325
|
-
channelId: channelId,
|
|
1326
|
-
userId: mark.userId,
|
|
1327
|
-
messageId: mark.messageId,
|
|
1328
|
-
sortId: mark.sortId
|
|
1329
|
-
});
|
|
1330
|
-
_a.label = 1;
|
|
1331
|
-
case 1:
|
|
1332
|
-
_a.trys.push([1, 3, , 4]);
|
|
1333
|
-
return [4 /*yield*/, updateSubscription(channelId, mark, JSON.stringify(option))];
|
|
1334
|
-
case 2:
|
|
1335
|
-
result = _a.sent();
|
|
1336
|
-
return [2 /*return*/, result["subscription"]];
|
|
1337
|
-
case 3:
|
|
1338
|
-
e_26 = _a.sent();
|
|
1339
|
-
throw e_26;
|
|
1340
|
-
case 4: return [2 /*return*/];
|
|
1341
|
-
}
|
|
1342
|
-
});
|
|
1343
|
-
});
|
|
1344
|
-
};
|
|
1345
|
-
/**
|
|
1346
|
-
* Add members to the private channel.
|
|
1347
|
-
*
|
|
1348
|
-
* @async
|
|
1349
|
-
* @function addUsers
|
|
1350
|
-
* @param {string} channelId - An private channel id.
|
|
1351
|
-
* @param {string[]} userIds - An array of member ids to be added.
|
|
1352
|
-
* @param {any} options
|
|
1353
|
-
* @returns {Promise<any>}
|
|
1354
|
-
*/
|
|
1355
|
-
NCloudChat.prototype.addUsers = function (channelId, userIds, options) {
|
|
1356
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1357
|
-
var result, e_27;
|
|
1358
|
-
return __generator(this, function (_a) {
|
|
1359
|
-
switch (_a.label) {
|
|
1360
|
-
case 0:
|
|
1361
|
-
this.inputValidation({
|
|
1362
|
-
channelId: channelId,
|
|
1363
|
-
userIds: userIds
|
|
1364
|
-
});
|
|
1365
|
-
_a.label = 1;
|
|
1366
|
-
case 1:
|
|
1367
|
-
_a.trys.push([1, 3, , 4]);
|
|
1368
|
-
return [4 /*yield*/, addChannelMembers(channelId, userIds, options)];
|
|
1369
|
-
case 2:
|
|
1370
|
-
result = _a.sent();
|
|
1371
|
-
if (result["channel"]) {
|
|
1372
|
-
result["channel"]["id"] = this.ObjectId(result["channel"]["id"]);
|
|
1373
|
-
result["channel"]["user_id"]["id"] = this.ObjectId(result["channel"]["user_id"]["id"]);
|
|
1374
|
-
}
|
|
1375
|
-
return [2 /*return*/, result["channel"]];
|
|
1376
|
-
case 3:
|
|
1377
|
-
e_27 = _a.sent();
|
|
1378
|
-
throw e_27;
|
|
1379
|
-
case 4: return [2 /*return*/];
|
|
1380
|
-
}
|
|
1381
|
-
});
|
|
1382
|
-
});
|
|
1383
|
-
};
|
|
1384
|
-
/**
|
|
1385
|
-
* Remove members from the private channel.
|
|
1386
|
-
*
|
|
1387
|
-
* @async
|
|
1388
|
-
* @function removeUsers
|
|
1389
|
-
* @param {string} channelId - An private channel id.
|
|
1390
|
-
* @param {string[]} userIds - An array of the member ids to be deleted.
|
|
1391
|
-
* @param {any} options
|
|
1392
|
-
* @returns {Promise<any>}
|
|
1393
|
-
*/
|
|
1394
|
-
NCloudChat.prototype.removeUsers = function (channelId, userIds, options) {
|
|
1395
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1396
|
-
var result, e_28;
|
|
1397
|
-
return __generator(this, function (_a) {
|
|
1398
|
-
switch (_a.label) {
|
|
1399
|
-
case 0:
|
|
1400
|
-
this.inputValidation({
|
|
1401
|
-
channelId: channelId,
|
|
1402
|
-
userIds: userIds
|
|
1403
|
-
});
|
|
1404
|
-
_a.label = 1;
|
|
1405
|
-
case 1:
|
|
1406
|
-
_a.trys.push([1, 3, , 4]);
|
|
1407
|
-
return [4 /*yield*/, removeChannelMembers(channelId, userIds)];
|
|
1408
|
-
case 2:
|
|
1409
|
-
result = _a.sent();
|
|
1410
|
-
if (result["channel"]) {
|
|
1411
|
-
result["channel"]["id"] = this.ObjectId(result["channel"]["id"]);
|
|
1412
|
-
result["channel"]["user_id"]["id"] = this.ObjectId(result["channel"]["user_id"]["id"]);
|
|
1413
|
-
}
|
|
1414
|
-
return [2 /*return*/, result["channel"]];
|
|
1415
|
-
case 3:
|
|
1416
|
-
e_28 = _a.sent();
|
|
1417
|
-
throw e_28;
|
|
1418
|
-
case 4: return [2 /*return*/];
|
|
1419
|
-
}
|
|
1420
|
-
});
|
|
1421
|
-
});
|
|
1422
|
-
};
|
|
1423
|
-
/**
|
|
1424
|
-
* Emit "start typing" to a conneted socket.
|
|
1425
|
-
*
|
|
1426
|
-
* @async
|
|
1427
|
-
* @function startTyping
|
|
1428
|
-
* @param {string} channelId - The id of a channel that the typing is happening.
|
|
1429
|
-
* @param {string} threadId - The id of a thread that the typing is happening.
|
|
1430
|
-
* @returns {Promise<any>}
|
|
1431
|
-
*/
|
|
1432
|
-
NCloudChat.prototype.startTyping = function (channelId, threadId) {
|
|
1433
|
-
if (threadId === void 0) { threadId = ""; }
|
|
1434
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1435
|
-
var data;
|
|
1436
|
-
return __generator(this, function (_a) {
|
|
1437
|
-
if (!this.isConnected())
|
|
1438
|
-
throw Error("You are not connected.");
|
|
1439
|
-
this.inputValidation({
|
|
1440
|
-
channelId: channelId,
|
|
1441
|
-
threadId: threadId
|
|
1442
|
-
});
|
|
1443
|
-
try {
|
|
1444
|
-
data = {
|
|
1445
|
-
channelId: channelId,
|
|
1446
|
-
threadId: threadId
|
|
1447
|
-
};
|
|
1448
|
-
this.socket.emit("start typing", data);
|
|
1449
|
-
return [2 /*return*/, data];
|
|
1450
|
-
}
|
|
1451
|
-
catch (e) {
|
|
1452
|
-
throw e;
|
|
1453
|
-
}
|
|
1454
|
-
return [2 /*return*/];
|
|
1455
|
-
});
|
|
1456
|
-
});
|
|
1457
|
-
};
|
|
1458
|
-
/**
|
|
1459
|
-
* Emit "stop typing" to a connected socket.
|
|
1460
|
-
*
|
|
1461
|
-
* @async
|
|
1462
|
-
* @function
|
|
1463
|
-
* @param {string} channelId - The id of a channel that the typing is stopped.
|
|
1464
|
-
* @param {string} threadId - The id of a thread that the typing is stopped.
|
|
1465
|
-
* @returns {Promise<any>}
|
|
1466
|
-
*/
|
|
1467
|
-
NCloudChat.prototype.stopTyping = function (channelId, threadId) {
|
|
1468
|
-
if (threadId === void 0) { threadId = ""; }
|
|
1469
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1470
|
-
var data;
|
|
1471
|
-
return __generator(this, function (_a) {
|
|
1472
|
-
if (!this.isConnected())
|
|
1473
|
-
throw Error("You are not connected.");
|
|
1474
|
-
this.inputValidation({
|
|
1475
|
-
channelId: channelId,
|
|
1476
|
-
threadId: threadId
|
|
1477
|
-
});
|
|
1478
|
-
try {
|
|
1479
|
-
data = {
|
|
1480
|
-
channelId: channelId,
|
|
1481
|
-
threadId: threadId
|
|
1482
|
-
};
|
|
1483
|
-
this.socket.emit("stop typing", data);
|
|
1484
|
-
return [2 /*return*/, data];
|
|
1485
|
-
}
|
|
1486
|
-
catch (e) {
|
|
1487
|
-
throw e;
|
|
1488
|
-
}
|
|
1489
|
-
return [2 /*return*/];
|
|
1490
|
-
});
|
|
1491
|
-
});
|
|
1492
|
-
};
|
|
1493
|
-
/**
|
|
1494
|
-
* Ban a member from a channel.
|
|
1495
|
-
*
|
|
1496
|
-
* @async
|
|
1497
|
-
* @function banUser
|
|
1498
|
-
* @param {string} channelId - The id of a channel.
|
|
1499
|
-
* @param {string} memberId - The id of a member.
|
|
1500
|
-
* @param {any} options
|
|
1501
|
-
* @returns {Promise<any>}
|
|
1502
|
-
*/
|
|
1503
|
-
NCloudChat.prototype.banUser = function (channelId, memberId, options) {
|
|
1504
|
-
if (options === void 0) { options = {}; }
|
|
1505
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1506
|
-
var memberBlock, e_29;
|
|
1507
|
-
return __generator(this, function (_a) {
|
|
1508
|
-
switch (_a.label) {
|
|
1509
|
-
case 0:
|
|
1510
|
-
this.inputValidation({
|
|
1511
|
-
channelId: channelId,
|
|
1512
|
-
memberId: memberId
|
|
1513
|
-
});
|
|
1514
|
-
_a.label = 1;
|
|
1515
|
-
case 1:
|
|
1516
|
-
_a.trys.push([1, 3, , 4]);
|
|
1517
|
-
return [4 /*yield*/, createMemberBlock(channelId, memberId, JSON.stringify(options))];
|
|
1518
|
-
case 2:
|
|
1519
|
-
memberBlock = _a.sent();
|
|
1520
|
-
if (memberBlock["memberBlock"])
|
|
1521
|
-
memberBlock["memberBlock"]["id"] = this.ObjectId(memberBlock["memberBlock"]["id"]);
|
|
1522
|
-
return [2 /*return*/, memberBlock["memberBlock"]];
|
|
1523
|
-
case 3:
|
|
1524
|
-
e_29 = _a.sent();
|
|
1525
|
-
throw e_29;
|
|
1526
|
-
case 4: return [2 /*return*/];
|
|
1527
|
-
}
|
|
1528
|
-
});
|
|
1529
|
-
});
|
|
1530
|
-
};
|
|
1531
|
-
/**
|
|
1532
|
-
* Unban a member from a channel.
|
|
1533
|
-
*
|
|
1534
|
-
* @async
|
|
1535
|
-
* @function unbanUser
|
|
1536
|
-
* @param {string} channelId - The id of a channel.
|
|
1537
|
-
* @param {string} memberId - The id of a member.
|
|
1538
|
-
* @returns {Promise<any>}
|
|
1539
|
-
*/
|
|
1540
|
-
NCloudChat.prototype.unbanUser = function (channelId, memberId) {
|
|
1541
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1542
|
-
var memberBlock, e_30;
|
|
1543
|
-
return __generator(this, function (_a) {
|
|
1544
|
-
switch (_a.label) {
|
|
1545
|
-
case 0:
|
|
1546
|
-
this.inputValidation({
|
|
1547
|
-
channelId: channelId,
|
|
1548
|
-
memberId: memberId
|
|
1549
|
-
});
|
|
1550
|
-
_a.label = 1;
|
|
1551
|
-
case 1:
|
|
1552
|
-
_a.trys.push([1, 3, , 4]);
|
|
1553
|
-
return [4 /*yield*/, deleteMemberBlock(channelId, memberId)];
|
|
1554
|
-
case 2:
|
|
1555
|
-
memberBlock = _a.sent();
|
|
1556
|
-
if (memberBlock["memberBlock"])
|
|
1557
|
-
memberBlock["memberBlock"]["id"] = this.ObjectId(memberBlock["memberBlock"]["id"]);
|
|
1558
|
-
return [2 /*return*/, memberBlock["memberBlock"]];
|
|
1559
|
-
case 3:
|
|
1560
|
-
e_30 = _a.sent();
|
|
1561
|
-
throw e_30;
|
|
1562
|
-
case 4: return [2 /*return*/];
|
|
1563
|
-
}
|
|
1564
|
-
});
|
|
1565
|
-
});
|
|
1566
|
-
};
|
|
1567
|
-
/**
|
|
1568
|
-
* Get data of a single pin from the endpoint.
|
|
1569
|
-
*
|
|
1570
|
-
* @async
|
|
1571
|
-
* @function getPin
|
|
1572
|
-
* @param {string} channelId - An id of the channel.
|
|
1573
|
-
* @param {string} id - An id of the pin.
|
|
1574
|
-
* @returns {Promise<any>} The data of the pin.
|
|
1575
|
-
*/
|
|
1576
|
-
NCloudChat.prototype.getPin = function (channelId, id) {
|
|
1577
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1578
|
-
var result, e_31;
|
|
1579
|
-
return __generator(this, function (_a) {
|
|
1580
|
-
switch (_a.label) {
|
|
1581
|
-
case 0:
|
|
1582
|
-
this.inputValidation({ channelId: channelId, pinId: id });
|
|
1583
|
-
_a.label = 1;
|
|
1584
|
-
case 1:
|
|
1585
|
-
_a.trys.push([1, 3, , 4]);
|
|
1586
|
-
return [4 /*yield*/, getPin(channelId, id)];
|
|
1587
|
-
case 2:
|
|
1588
|
-
result = _a.sent();
|
|
1589
|
-
if (result) {
|
|
1590
|
-
result.id = this.ObjectId(result.id);
|
|
1591
|
-
if (result["user_id"]) {
|
|
1592
|
-
result["user_id"]["id"] = this.ObjectId(result["user_id"]["id"]);
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
return [2 /*return*/, result];
|
|
1596
|
-
case 3:
|
|
1597
|
-
e_31 = _a.sent();
|
|
1598
|
-
throw e_31;
|
|
1599
|
-
case 4: return [2 /*return*/];
|
|
1600
|
-
}
|
|
1601
|
-
});
|
|
1602
|
-
});
|
|
1603
|
-
};
|
|
1604
|
-
/**
|
|
1605
|
-
* Get data of multiple pins.
|
|
1606
|
-
*
|
|
1607
|
-
* @async
|
|
1608
|
-
* @function getPins
|
|
1609
|
-
* @param {string} channelId - An id of the channel.
|
|
1610
|
-
* @param {string} filter - Field value for filter.
|
|
1611
|
-
* @param {string} sort - Field value for sorting.
|
|
1612
|
-
* @param {string} option - Optional option: ex) offset, per_page.
|
|
1613
|
-
* @returns {Promise<any[]>} An array of data of all channels.
|
|
1614
|
-
*/
|
|
1615
|
-
NCloudChat.prototype.getPins = function (channelId, filter, sort, option) {
|
|
1616
|
-
if (sort === void 0) { sort = {}; }
|
|
1617
|
-
if (option === void 0) { option = {}; }
|
|
1618
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1619
|
-
var entries, channels, e_32;
|
|
1620
|
-
var _this = this;
|
|
1621
|
-
return __generator(this, function (_a) {
|
|
1622
|
-
switch (_a.label) {
|
|
1623
|
-
case 0:
|
|
1624
|
-
this.inputValidation({});
|
|
1625
|
-
_a.label = 1;
|
|
1626
|
-
case 1:
|
|
1627
|
-
_a.trys.push([1, 3, , 4]);
|
|
1628
|
-
return [4 /*yield*/, getPins(channelId, JSON.stringify(filter), JSON.stringify(sort), JSON.stringify(option))];
|
|
1629
|
-
case 2:
|
|
1630
|
-
entries = _a.sent();
|
|
1631
|
-
if (entries["edges"]) {
|
|
1632
|
-
channels = entries["edges"].map(function (item) {
|
|
1633
|
-
var _a, _b;
|
|
1634
|
-
if (item.node.user_id)
|
|
1635
|
-
item.node.user_id.id = _this.ObjectId((_b = (_a = item.node) === null || _a === void 0 ? void 0 : _a.user_id) === null || _b === void 0 ? void 0 : _b.id);
|
|
1636
|
-
return __assign(__assign({}, item.node), { id: _this.ObjectId(item.node.id) });
|
|
1637
|
-
});
|
|
1638
|
-
return [2 /*return*/, channels];
|
|
1639
|
-
}
|
|
1640
|
-
return [2 /*return*/, entries["edges"]];
|
|
1641
|
-
case 3:
|
|
1642
|
-
e_32 = _a.sent();
|
|
1643
|
-
throw e_32;
|
|
1644
|
-
case 4: return [2 /*return*/];
|
|
1645
|
-
}
|
|
1646
|
-
});
|
|
1647
|
-
});
|
|
1648
|
-
};
|
|
1649
|
-
/**
|
|
1650
|
-
* Create a new pin.
|
|
1651
|
-
*
|
|
1652
|
-
* @async
|
|
1653
|
-
* @function createPin
|
|
1654
|
-
* @param {string} channelId - An id of the channel.
|
|
1655
|
-
* @param {PinInput} pin - Configuration options of the new pin.
|
|
1656
|
-
* @returns {Promise<any>} The data of the newly created pin.
|
|
1657
|
-
*/
|
|
1658
|
-
NCloudChat.prototype.createPin = function (channelId, pin) {
|
|
1659
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1660
|
-
var result, e_33;
|
|
1661
|
-
return __generator(this, function (_a) {
|
|
1662
|
-
switch (_a.label) {
|
|
1663
|
-
case 0:
|
|
1664
|
-
this.inputValidation({
|
|
1665
|
-
channelId: channelId,
|
|
1666
|
-
pinned: pin.pinned
|
|
1667
|
-
});
|
|
1668
|
-
_a.label = 1;
|
|
1669
|
-
case 1:
|
|
1670
|
-
_a.trys.push([1, 3, , 4]);
|
|
1671
|
-
return [4 /*yield*/, createPin(channelId, pin)];
|
|
1672
|
-
case 2:
|
|
1673
|
-
result = _a.sent();
|
|
1674
|
-
if (result["pin"]) {
|
|
1675
|
-
result["pin"]["id"] = this.ObjectId(result["pin"]["id"]);
|
|
1676
|
-
result["pin"]["user_id"]["id"] = this.ObjectId(result["pin"]["user_id"]["id"]);
|
|
1677
|
-
}
|
|
1678
|
-
return [2 /*return*/, result["pin"]];
|
|
1679
|
-
case 3:
|
|
1680
|
-
e_33 = _a.sent();
|
|
1681
|
-
throw e_33;
|
|
1682
|
-
case 4: return [2 /*return*/];
|
|
1683
|
-
}
|
|
1684
|
-
});
|
|
1685
|
-
});
|
|
1686
|
-
};
|
|
1687
|
-
/**
|
|
1688
|
-
* Update pin options.
|
|
1689
|
-
*
|
|
1690
|
-
* @async
|
|
1691
|
-
* @function updatePin
|
|
1692
|
-
* @param {string} channelId - An id of the channel.
|
|
1693
|
-
* @param {PinInput} pin - New options of the pin.
|
|
1694
|
-
* @returns {Promise<any>} The data of the updated pin.
|
|
1695
|
-
*/
|
|
1696
|
-
NCloudChat.prototype.updatePin = function (pinId, channelId, pin) {
|
|
1697
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1698
|
-
var result, e_34;
|
|
1699
|
-
return __generator(this, function (_a) {
|
|
1700
|
-
switch (_a.label) {
|
|
1701
|
-
case 0:
|
|
1702
|
-
this.inputValidation({
|
|
1703
|
-
channelId: channelId,
|
|
1704
|
-
pinned: pin.pinned
|
|
1705
|
-
});
|
|
1706
|
-
_a.label = 1;
|
|
1707
|
-
case 1:
|
|
1708
|
-
_a.trys.push([1, 3, , 4]);
|
|
1709
|
-
return [4 /*yield*/, updatePin(pinId, channelId, pin)];
|
|
1710
|
-
case 2:
|
|
1711
|
-
result = _a.sent();
|
|
1712
|
-
if (result["pin"]) {
|
|
1713
|
-
result["pin"]["id"] = this.ObjectId(result["pin"]["id"]);
|
|
1714
|
-
result["pin"]["user_id"]["id"] = this.ObjectId(result["pin"]["user_id"]["id"]);
|
|
1715
|
-
}
|
|
1716
|
-
return [2 /*return*/, result["pin"]];
|
|
1717
|
-
case 3:
|
|
1718
|
-
e_34 = _a.sent();
|
|
1719
|
-
throw e_34;
|
|
1720
|
-
case 4: return [2 /*return*/];
|
|
1721
|
-
}
|
|
1722
|
-
});
|
|
1723
|
-
});
|
|
1724
|
-
};
|
|
1725
|
-
NCloudChat.prototype.getServerUrl = function () {
|
|
1726
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1727
|
-
return __generator(this, function (_a) {
|
|
1728
|
-
return [2 /*return*/, CoreManager.get("SERVER_URL")];
|
|
1729
|
-
});
|
|
1730
|
-
});
|
|
1731
|
-
};
|
|
1732
|
-
return NCloudChat;
|
|
1733
|
-
}());
|
|
1734
|
-
export default NCloudChat;
|
|
1735
|
-
//# sourceMappingURL=CloudChat.js.map
|