lemmy-js-client 0.17.2-rc.21 → 0.17.2-rc.23
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/http.d.ts +1 -5
- package/dist/http.js +340 -393
- package/dist/websocket.js +180 -182
- package/package.json +11 -4
package/dist/http.js
CHANGED
@@ -1,15 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
3
|
-
__assign = Object.assign || function(t) {
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
-
s = arguments[i];
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
-
t[p] = s[p];
|
8
|
-
}
|
9
|
-
return t;
|
10
|
-
};
|
11
|
-
return __assign.apply(this, arguments);
|
12
|
-
};
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -19,41 +8,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
19
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
20
9
|
});
|
21
10
|
};
|
22
|
-
var
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
case 0: case 1: t = op; break;
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
36
|
-
default:
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
41
|
-
if (t[2]) _.ops.pop();
|
42
|
-
_.trys.pop(); continue;
|
43
|
-
}
|
44
|
-
op = body.call(thisArg, _);
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
47
|
-
}
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
16
|
+
};
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
19
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
48
21
|
};
|
49
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
50
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
51
24
|
};
|
25
|
+
var _LemmyHttp_instances, _LemmyHttp_apiUrl, _LemmyHttp_headers, _LemmyHttp_pictrsUrl, _LemmyHttp_buildFullUrl, _LemmyHttp_wrapper;
|
52
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
53
27
|
exports.LemmyHttp = void 0;
|
54
|
-
|
55
|
-
|
56
|
-
|
28
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
29
|
+
const form_data_1 = __importDefault(require("form-data"));
|
30
|
+
const others_1 = require("./types/others");
|
57
31
|
var HttpType;
|
58
32
|
(function (HttpType) {
|
59
33
|
HttpType["Get"] = "GET";
|
@@ -63,18 +37,21 @@ var HttpType;
|
|
63
37
|
/**
|
64
38
|
* Helps build lemmy HTTP requests.
|
65
39
|
*/
|
66
|
-
|
40
|
+
class LemmyHttp {
|
67
41
|
/**
|
68
42
|
* Generates a new instance of LemmyHttp.
|
69
43
|
* @param baseUrl the base url, without the vX version: https://lemmy.ml -> goes to https://lemmy.ml/api/vX
|
70
44
|
* @param headers optional headers. Should contain `x-real-ip` and `x-forwarded-for` .
|
71
45
|
*/
|
72
|
-
|
73
|
-
this
|
74
|
-
|
75
|
-
|
46
|
+
constructor(baseUrl, headers) {
|
47
|
+
_LemmyHttp_instances.add(this);
|
48
|
+
_LemmyHttp_apiUrl.set(this, void 0);
|
49
|
+
_LemmyHttp_headers.set(this, {});
|
50
|
+
_LemmyHttp_pictrsUrl.set(this, void 0);
|
51
|
+
__classPrivateFieldSet(this, _LemmyHttp_apiUrl, `${baseUrl}/api/${others_1.VERSION}`, "f");
|
52
|
+
__classPrivateFieldSet(this, _LemmyHttp_pictrsUrl, `${baseUrl}/pictrs/image`, "f");
|
76
53
|
if (headers) {
|
77
|
-
this
|
54
|
+
__classPrivateFieldSet(this, _LemmyHttp_headers, headers, "f");
|
78
55
|
}
|
79
56
|
}
|
80
57
|
/**
|
@@ -82,788 +59,758 @@ var LemmyHttp = /** @class */ (function () {
|
|
82
59
|
*
|
83
60
|
* `HTTP.GET /site`
|
84
61
|
*/
|
85
|
-
|
86
|
-
return this.
|
87
|
-
}
|
62
|
+
getSite(form) {
|
63
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/site", form);
|
64
|
+
}
|
88
65
|
/**
|
89
66
|
* Create your site.
|
90
67
|
*
|
91
68
|
* `HTTP.POST /site`
|
92
69
|
*/
|
93
|
-
|
94
|
-
return this.
|
95
|
-
}
|
70
|
+
createSite(form) {
|
71
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/site", form);
|
72
|
+
}
|
96
73
|
/**
|
97
74
|
* Edit your site.
|
98
75
|
*
|
99
76
|
* `HTTP.PUT /site`
|
100
77
|
*/
|
101
|
-
|
102
|
-
return this.
|
103
|
-
}
|
78
|
+
editSite(form) {
|
79
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/site", form);
|
80
|
+
}
|
104
81
|
/**
|
105
82
|
* Leave the Site admins.
|
106
83
|
*
|
107
84
|
* `HTTP.POST /user/leave_admin`
|
108
85
|
*/
|
109
|
-
|
110
|
-
return this.
|
111
|
-
}
|
86
|
+
leaveAdmin(form) {
|
87
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/leave_admin", form);
|
88
|
+
}
|
112
89
|
/**
|
113
90
|
* Get the modlog.
|
114
91
|
*
|
115
92
|
* `HTTP.GET /modlog`
|
116
93
|
*/
|
117
|
-
|
118
|
-
return this.
|
119
|
-
}
|
94
|
+
getModlog(form) {
|
95
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/modlog", form);
|
96
|
+
}
|
120
97
|
/**
|
121
98
|
* Search lemmy.
|
122
99
|
*
|
123
100
|
* `HTTP.GET /search`
|
124
101
|
*/
|
125
|
-
|
126
|
-
return this.
|
127
|
-
}
|
102
|
+
search(form) {
|
103
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/search", form);
|
104
|
+
}
|
128
105
|
/**
|
129
106
|
* Fetch a non-local / federated object.
|
130
107
|
*
|
131
108
|
* `HTTP.GET /resolve_object`
|
132
109
|
*/
|
133
|
-
|
134
|
-
return this.
|
135
|
-
}
|
110
|
+
resolveObject(form) {
|
111
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/resolve_object", form);
|
112
|
+
}
|
136
113
|
/**
|
137
114
|
* Create a new community.
|
138
115
|
*
|
139
116
|
* `HTTP.POST /community`
|
140
117
|
*/
|
141
|
-
|
142
|
-
return this.
|
143
|
-
}
|
118
|
+
createCommunity(form) {
|
119
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community", form);
|
120
|
+
}
|
144
121
|
/**
|
145
122
|
* Get / fetch a community.
|
146
123
|
*
|
147
124
|
* `HTTP.GET /community`
|
148
125
|
*/
|
149
|
-
|
150
|
-
return this.
|
151
|
-
}
|
126
|
+
getCommunity(form) {
|
127
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/community", form);
|
128
|
+
}
|
152
129
|
/**
|
153
130
|
* Edit a community.
|
154
131
|
*
|
155
132
|
* `HTTP.PUT /community`
|
156
133
|
*/
|
157
|
-
|
158
|
-
return this.
|
159
|
-
}
|
134
|
+
editCommunity(form) {
|
135
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/community", form);
|
136
|
+
}
|
160
137
|
/**
|
161
138
|
* List communities, with various filters.
|
162
139
|
*
|
163
140
|
* `HTTP.GET /community/list`
|
164
141
|
*/
|
165
|
-
|
166
|
-
return this.
|
167
|
-
}
|
142
|
+
listCommunities(form) {
|
143
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/community/list", form);
|
144
|
+
}
|
168
145
|
/**
|
169
146
|
* Follow / subscribe to a community.
|
170
147
|
*
|
171
148
|
* `HTTP.POST /community/follow`
|
172
149
|
*/
|
173
|
-
|
174
|
-
return this.
|
175
|
-
}
|
150
|
+
followCommunity(form) {
|
151
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/follow", form);
|
152
|
+
}
|
176
153
|
/**
|
177
154
|
* Block a community.
|
178
155
|
*
|
179
156
|
* `HTTP.POST /community/block`
|
180
157
|
*/
|
181
|
-
|
182
|
-
return this.
|
183
|
-
}
|
158
|
+
blockCommunity(form) {
|
159
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/block", form);
|
160
|
+
}
|
184
161
|
/**
|
185
162
|
* Delete a community.
|
186
163
|
*
|
187
164
|
* `HTTP.POST /community/delete`
|
188
165
|
*/
|
189
|
-
|
190
|
-
return this.
|
191
|
-
}
|
166
|
+
deleteCommunity(form) {
|
167
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/delete", form);
|
168
|
+
}
|
192
169
|
/**
|
193
170
|
* A moderator remove for a community.
|
194
171
|
*
|
195
172
|
* `HTTP.POST /community/remove`
|
196
173
|
*/
|
197
|
-
|
198
|
-
return this.
|
199
|
-
}
|
174
|
+
removeCommunity(form) {
|
175
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/remove", form);
|
176
|
+
}
|
200
177
|
/**
|
201
178
|
* Transfer your community to an existing moderator.
|
202
179
|
*
|
203
180
|
* `HTTP.POST /community/transfer`
|
204
181
|
*/
|
205
|
-
|
206
|
-
return this.
|
207
|
-
}
|
182
|
+
transferCommunity(form) {
|
183
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/transfer", form);
|
184
|
+
}
|
208
185
|
/**
|
209
186
|
* Ban a user from a community.
|
210
187
|
*
|
211
188
|
* `HTTP.POST /community/ban_user`
|
212
189
|
*/
|
213
|
-
|
214
|
-
return this.
|
215
|
-
}
|
190
|
+
banFromCommunity(form) {
|
191
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/ban_user", form);
|
192
|
+
}
|
216
193
|
/**
|
217
194
|
* Add a moderator to your community.
|
218
195
|
*
|
219
196
|
* `HTTP.POST /community/mod`
|
220
197
|
*/
|
221
|
-
|
222
|
-
return this.
|
223
|
-
}
|
198
|
+
addModToCommunity(form) {
|
199
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/mod", form);
|
200
|
+
}
|
224
201
|
/**
|
225
202
|
* Create a post.
|
226
203
|
*
|
227
204
|
* `HTTP.POST /post`
|
228
205
|
*/
|
229
|
-
|
230
|
-
return this.
|
231
|
-
}
|
206
|
+
createPost(form) {
|
207
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post", form);
|
208
|
+
}
|
232
209
|
/**
|
233
210
|
* Get / fetch a post.
|
234
211
|
*
|
235
212
|
* `HTTP.GET /post`
|
236
213
|
*/
|
237
|
-
|
238
|
-
return this.
|
239
|
-
}
|
214
|
+
getPost(form) {
|
215
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/post", form);
|
216
|
+
}
|
240
217
|
/**
|
241
218
|
* Edit a post.
|
242
219
|
*
|
243
220
|
* `HTTP.PUT /post`
|
244
221
|
*/
|
245
|
-
|
246
|
-
return this.
|
247
|
-
}
|
222
|
+
editPost(form) {
|
223
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/post", form);
|
224
|
+
}
|
248
225
|
/**
|
249
226
|
* Delete a post.
|
250
227
|
*
|
251
228
|
* `HTTP.POST /post/delete`
|
252
229
|
*/
|
253
|
-
|
254
|
-
return this.
|
255
|
-
}
|
230
|
+
deletePost(form) {
|
231
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/delete", form);
|
232
|
+
}
|
256
233
|
/**
|
257
234
|
* A moderator remove for a post.
|
258
235
|
*
|
259
236
|
* `HTTP.POST /post/remove`
|
260
237
|
*/
|
261
|
-
|
262
|
-
return this.
|
263
|
-
}
|
238
|
+
removePost(form) {
|
239
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/remove", form);
|
240
|
+
}
|
264
241
|
/**
|
265
242
|
* Mark a post as read.
|
266
243
|
*
|
267
244
|
* `HTTP.POST /post/mark_as_read`
|
268
245
|
*/
|
269
|
-
|
270
|
-
return this.
|
271
|
-
}
|
246
|
+
markPostAsRead(form) {
|
247
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/mark_as_read", form);
|
248
|
+
}
|
272
249
|
/**
|
273
250
|
* A moderator can lock a post ( IE disable new comments ).
|
274
251
|
*
|
275
252
|
* `HTTP.POST /post/lock`
|
276
253
|
*/
|
277
|
-
|
278
|
-
return this.
|
279
|
-
}
|
254
|
+
lockPost(form) {
|
255
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/lock", form);
|
256
|
+
}
|
280
257
|
/**
|
281
258
|
* A moderator can feature a community post ( IE stick it to the top of a community ).
|
282
259
|
*
|
283
260
|
* `HTTP.POST /post/feature`
|
284
261
|
*/
|
285
|
-
|
286
|
-
return this.
|
287
|
-
}
|
262
|
+
featurePost(form) {
|
263
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/feature", form);
|
264
|
+
}
|
288
265
|
/**
|
289
266
|
* Get / fetch posts, with various filters.
|
290
267
|
*
|
291
268
|
* `HTTP.GET /post/list`
|
292
269
|
*/
|
293
|
-
|
294
|
-
return this.
|
295
|
-
}
|
270
|
+
getPosts(form) {
|
271
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/post/list", form);
|
272
|
+
}
|
296
273
|
/**
|
297
274
|
* Like / vote on a post.
|
298
275
|
*
|
299
276
|
* `HTTP.POST /post/like`
|
300
277
|
*/
|
301
|
-
|
302
|
-
return this.
|
303
|
-
}
|
278
|
+
likePost(form) {
|
279
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/like", form);
|
280
|
+
}
|
304
281
|
/**
|
305
282
|
* Save a post.
|
306
283
|
*
|
307
284
|
* `HTTP.PUT /post/save`
|
308
285
|
*/
|
309
|
-
|
310
|
-
return this.
|
311
|
-
}
|
286
|
+
savePost(form) {
|
287
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/post/save", form);
|
288
|
+
}
|
312
289
|
/**
|
313
290
|
* Report a post.
|
314
291
|
*
|
315
292
|
* `HTTP.POST /post/report`
|
316
293
|
*/
|
317
|
-
|
318
|
-
return this.
|
319
|
-
}
|
294
|
+
createPostReport(form) {
|
295
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/report", form);
|
296
|
+
}
|
320
297
|
/**
|
321
298
|
* Resolve a post report. Only a mod can do this.
|
322
299
|
*
|
323
300
|
* `HTTP.PUT /post/report/resolve`
|
324
301
|
*/
|
325
|
-
|
326
|
-
return this.
|
327
|
-
}
|
302
|
+
resolvePostReport(form) {
|
303
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/post/report/resolve", form);
|
304
|
+
}
|
328
305
|
/**
|
329
306
|
* List post reports.
|
330
307
|
*
|
331
308
|
* `HTTP.GET /post/report/list`
|
332
309
|
*/
|
333
|
-
|
334
|
-
return this.
|
335
|
-
}
|
310
|
+
listPostReports(form) {
|
311
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/post/report/list", form);
|
312
|
+
}
|
336
313
|
/**
|
337
314
|
* Fetch metadata for any given site.
|
338
315
|
*
|
339
316
|
* `HTTP.GET /post/site_metadata`
|
340
317
|
*/
|
341
|
-
|
342
|
-
return this.
|
343
|
-
}
|
318
|
+
getSiteMetadata(form) {
|
319
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/post/site_metadata", form);
|
320
|
+
}
|
344
321
|
/**
|
345
322
|
* Create a comment.
|
346
323
|
*
|
347
324
|
* `HTTP.POST /comment`
|
348
325
|
*/
|
349
|
-
|
350
|
-
return this.
|
351
|
-
}
|
326
|
+
createComment(form) {
|
327
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment", form);
|
328
|
+
}
|
352
329
|
/**
|
353
330
|
* Edit a comment.
|
354
331
|
*
|
355
332
|
* `HTTP.PUT /comment`
|
356
333
|
*/
|
357
|
-
|
358
|
-
return this.
|
359
|
-
}
|
334
|
+
editComment(form) {
|
335
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/comment", form);
|
336
|
+
}
|
360
337
|
/**
|
361
338
|
* Delete a comment.
|
362
339
|
*
|
363
340
|
* `HTTP.POST /comment/delete`
|
364
341
|
*/
|
365
|
-
|
366
|
-
return this.
|
367
|
-
}
|
342
|
+
deleteComment(form) {
|
343
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/delete", form);
|
344
|
+
}
|
368
345
|
/**
|
369
346
|
* A moderator remove for a comment.
|
370
347
|
*
|
371
348
|
* `HTTP.POST /comment/remove`
|
372
349
|
*/
|
373
|
-
|
374
|
-
return this.
|
375
|
-
}
|
350
|
+
removeComment(form) {
|
351
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/remove", form);
|
352
|
+
}
|
376
353
|
/**
|
377
354
|
* Mark a comment as read.
|
378
355
|
*
|
379
356
|
* `HTTP.POST /comment/mark_as_read`
|
380
357
|
*/
|
381
|
-
|
382
|
-
return this.
|
383
|
-
}
|
358
|
+
markCommentReplyAsRead(form) {
|
359
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/mark_as_read", form);
|
360
|
+
}
|
384
361
|
/**
|
385
362
|
* Like / vote on a comment.
|
386
363
|
*
|
387
364
|
* `HTTP.POST /comment/like`
|
388
365
|
*/
|
389
|
-
|
390
|
-
return this.
|
391
|
-
}
|
366
|
+
likeComment(form) {
|
367
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/like", form);
|
368
|
+
}
|
392
369
|
/**
|
393
370
|
* Save a comment.
|
394
371
|
*
|
395
372
|
* `HTTP.PUT /comment/save`
|
396
373
|
*/
|
397
|
-
|
398
|
-
return this.
|
399
|
-
}
|
374
|
+
saveComment(form) {
|
375
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/comment/save", form);
|
376
|
+
}
|
400
377
|
/**
|
401
378
|
* Distinguishes a comment (speak as moderator)
|
402
379
|
*
|
403
380
|
* `HTTP.POST /comment/distinguish`
|
404
381
|
*/
|
405
|
-
|
406
|
-
return this.
|
407
|
-
}
|
382
|
+
distinguishComment(form) {
|
383
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/distinguish", form);
|
384
|
+
}
|
408
385
|
/**
|
409
386
|
* Get / fetch comments.
|
410
387
|
*
|
411
388
|
* `HTTP.GET /comment/list`
|
412
389
|
*/
|
413
|
-
|
414
|
-
return this.
|
415
|
-
}
|
390
|
+
getComments(form) {
|
391
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/comment/list", form);
|
392
|
+
}
|
416
393
|
/**
|
417
394
|
* Get / fetch comment.
|
418
395
|
*
|
419
396
|
* `HTTP.GET /comment`
|
420
397
|
*/
|
421
|
-
|
422
|
-
return this.
|
423
|
-
}
|
398
|
+
getComment(form) {
|
399
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/comment", form);
|
400
|
+
}
|
424
401
|
/**
|
425
402
|
* Report a comment.
|
426
403
|
*
|
427
404
|
* `HTTP.POST /comment/report`
|
428
405
|
*/
|
429
|
-
|
430
|
-
return this.
|
431
|
-
}
|
406
|
+
createCommentReport(form) {
|
407
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/report", form);
|
408
|
+
}
|
432
409
|
/**
|
433
410
|
* Resolve a comment report. Only a mod can do this.
|
434
411
|
*
|
435
412
|
* `HTTP.PUT /comment/report/resolve`
|
436
413
|
*/
|
437
|
-
|
438
|
-
return this.
|
439
|
-
}
|
414
|
+
resolveCommentReport(form) {
|
415
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/comment/report/resolve", form);
|
416
|
+
}
|
440
417
|
/**
|
441
418
|
* List comment reports.
|
442
419
|
*
|
443
420
|
* `HTTP.GET /comment/report/list`
|
444
421
|
*/
|
445
|
-
|
446
|
-
return this.
|
447
|
-
}
|
422
|
+
listCommentReports(form) {
|
423
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/comment/report/list", form);
|
424
|
+
}
|
448
425
|
/**
|
449
426
|
* Get / fetch private messages.
|
450
427
|
*
|
451
428
|
* `HTTP.GET /private_message/list`
|
452
429
|
*/
|
453
|
-
|
454
|
-
return this.
|
455
|
-
}
|
430
|
+
getPrivateMessages(form) {
|
431
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/private_message/list", form);
|
432
|
+
}
|
456
433
|
/**
|
457
434
|
* Create a private message.
|
458
435
|
*
|
459
436
|
* `HTTP.POST /private_message`
|
460
437
|
*/
|
461
|
-
|
462
|
-
return this.
|
463
|
-
}
|
438
|
+
createPrivateMessage(form) {
|
439
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/private_message", form);
|
440
|
+
}
|
464
441
|
/**
|
465
442
|
* Edit a private message.
|
466
443
|
*
|
467
444
|
* `HTTP.PUT /private_message`
|
468
445
|
*/
|
469
|
-
|
470
|
-
return this.
|
471
|
-
}
|
446
|
+
editPrivateMessage(form) {
|
447
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/private_message", form);
|
448
|
+
}
|
472
449
|
/**
|
473
450
|
* Delete a private message.
|
474
451
|
*
|
475
452
|
* `HTTP.POST /private_message/delete`
|
476
453
|
*/
|
477
|
-
|
478
|
-
return this.
|
479
|
-
}
|
454
|
+
deletePrivateMessage(form) {
|
455
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/private_message/delete", form);
|
456
|
+
}
|
480
457
|
/**
|
481
458
|
* Mark a private message as read.
|
482
459
|
*
|
483
460
|
* `HTTP.POST /private_message/mark_as_read`
|
484
461
|
*/
|
485
|
-
|
486
|
-
return this.
|
487
|
-
}
|
462
|
+
markPrivateMessageAsRead(form) {
|
463
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/private_message/mark_as_read", form);
|
464
|
+
}
|
488
465
|
/**
|
489
466
|
* Create a report for a private message.
|
490
467
|
*
|
491
468
|
* `HTTP.POST /private_message/report`
|
492
469
|
*/
|
493
|
-
|
494
|
-
return this.
|
495
|
-
}
|
470
|
+
createPrivateMessageReport(form) {
|
471
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/private_message/report", form);
|
472
|
+
}
|
496
473
|
/**
|
497
474
|
* Resolve a report for a private message.
|
498
475
|
*
|
499
476
|
* `HTTP.PUT /private_message/report/resolve`
|
500
477
|
*/
|
501
|
-
|
502
|
-
return this.
|
503
|
-
}
|
478
|
+
resolvePrivateMessageReport(form) {
|
479
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/private_message/report/resolve", form);
|
480
|
+
}
|
504
481
|
/**
|
505
482
|
* List private message reports.
|
506
483
|
*
|
507
484
|
* `HTTP.GET /private_message/report/list`
|
508
485
|
*/
|
509
|
-
|
510
|
-
return this.
|
511
|
-
}
|
486
|
+
listPrivateMessageReports(form) {
|
487
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/private_message/report/list", form);
|
488
|
+
}
|
512
489
|
/**
|
513
490
|
* Register a new user.
|
514
491
|
*
|
515
492
|
* `HTTP.POST /user/register`
|
516
493
|
*/
|
517
|
-
|
518
|
-
return this.
|
519
|
-
}
|
494
|
+
register(form) {
|
495
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/register", form);
|
496
|
+
}
|
520
497
|
/**
|
521
498
|
* Log into lemmy.
|
522
499
|
*
|
523
500
|
* `HTTP.POST /user/login`
|
524
501
|
*/
|
525
|
-
|
526
|
-
return this.
|
527
|
-
}
|
502
|
+
login(form) {
|
503
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/login", form);
|
504
|
+
}
|
528
505
|
/**
|
529
506
|
* Get the details for a person.
|
530
507
|
*
|
531
508
|
* `HTTP.GET /user`
|
532
509
|
*/
|
533
|
-
|
534
|
-
return this.
|
535
|
-
}
|
510
|
+
getPersonDetails(form) {
|
511
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user", form);
|
512
|
+
}
|
536
513
|
/**
|
537
514
|
* Get mentions for your user.
|
538
515
|
*
|
539
516
|
* `HTTP.GET /user/mention`
|
540
517
|
*/
|
541
|
-
|
542
|
-
return this.
|
543
|
-
}
|
518
|
+
getPersonMentions(form) {
|
519
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/mention", form);
|
520
|
+
}
|
544
521
|
/**
|
545
522
|
* Mark a person mention as read.
|
546
523
|
*
|
547
524
|
* `HTTP.POST /user/mention/mark_as_read`
|
548
525
|
*/
|
549
|
-
|
550
|
-
return this.
|
551
|
-
}
|
526
|
+
markPersonMentionAsRead(form) {
|
527
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/mention/mark_as_read", form);
|
528
|
+
}
|
552
529
|
/**
|
553
530
|
* Get comment replies.
|
554
531
|
*
|
555
532
|
* `HTTP.GET /user/replies`
|
556
533
|
*/
|
557
|
-
|
558
|
-
return this.
|
559
|
-
}
|
534
|
+
getReplies(form) {
|
535
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/replies", form);
|
536
|
+
}
|
560
537
|
/**
|
561
538
|
* Ban a person from your site.
|
562
539
|
*
|
563
540
|
* `HTTP.POST /user/ban`
|
564
541
|
*/
|
565
|
-
|
566
|
-
return this.
|
567
|
-
}
|
542
|
+
banPerson(form) {
|
543
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/ban", form);
|
544
|
+
}
|
568
545
|
/**
|
569
546
|
* Get a list of banned users
|
570
547
|
*
|
571
548
|
* `HTTP.GET /user/banned`
|
572
549
|
*/
|
573
|
-
|
574
|
-
return this.
|
575
|
-
}
|
550
|
+
getBannedPersons(form) {
|
551
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/banned", form);
|
552
|
+
}
|
576
553
|
/**
|
577
554
|
* Block a person.
|
578
555
|
*
|
579
556
|
* `HTTP.POST /user/block`
|
580
557
|
*/
|
581
|
-
|
582
|
-
return this.
|
583
|
-
}
|
558
|
+
blockPerson(form) {
|
559
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/block", form);
|
560
|
+
}
|
584
561
|
/**
|
585
562
|
* Fetch a Captcha.
|
586
563
|
*
|
587
564
|
* `HTTP.GET /user/get_captcha`
|
588
565
|
*/
|
589
|
-
|
590
|
-
return this.
|
591
|
-
}
|
566
|
+
getCaptcha(form) {
|
567
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/get_captcha", form);
|
568
|
+
}
|
592
569
|
/**
|
593
570
|
* Delete your account.
|
594
571
|
*
|
595
572
|
* `HTTP.POST /user/delete_account`
|
596
573
|
*/
|
597
|
-
|
598
|
-
return this.
|
599
|
-
}
|
574
|
+
deleteAccount(form) {
|
575
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/delete_account", form);
|
576
|
+
}
|
600
577
|
/**
|
601
578
|
* Reset your password.
|
602
579
|
*
|
603
580
|
* `HTTP.POST /user/password_reset`
|
604
581
|
*/
|
605
|
-
|
606
|
-
return this.
|
607
|
-
}
|
582
|
+
passwordReset(form) {
|
583
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/password_reset", form);
|
584
|
+
}
|
608
585
|
/**
|
609
586
|
* Change your password from an email / token based reset.
|
610
587
|
*
|
611
588
|
* `HTTP.POST /user/password_change`
|
612
589
|
*/
|
613
|
-
|
614
|
-
return this.
|
615
|
-
}
|
590
|
+
passwordChangeAfterReset(form) {
|
591
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/password_change", form);
|
592
|
+
}
|
616
593
|
/**
|
617
594
|
* Mark all replies as read.
|
618
595
|
*
|
619
596
|
* `HTTP.POST /user/mark_all_as_read`
|
620
597
|
*/
|
621
|
-
|
622
|
-
return this.
|
623
|
-
}
|
598
|
+
markAllAsRead(form) {
|
599
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/mark_all_as_read", form);
|
600
|
+
}
|
624
601
|
/**
|
625
602
|
* Save your user settings.
|
626
603
|
*
|
627
604
|
* `HTTP.PUT /user/save_user_settings`
|
628
605
|
*/
|
629
|
-
|
630
|
-
return this.
|
631
|
-
}
|
606
|
+
saveUserSettings(form) {
|
607
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/user/save_user_settings", form);
|
608
|
+
}
|
632
609
|
/**
|
633
610
|
* Change your user password.
|
634
611
|
*
|
635
612
|
* `HTTP.PUT /user/change_password`
|
636
613
|
*/
|
637
|
-
|
638
|
-
return this.
|
639
|
-
}
|
614
|
+
changePassword(form) {
|
615
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/user/change_password", form);
|
616
|
+
}
|
640
617
|
/**
|
641
618
|
* Get counts for your reports
|
642
619
|
*
|
643
620
|
* `HTTP.GET /user/report_count`
|
644
621
|
*/
|
645
|
-
|
646
|
-
return this.
|
647
|
-
}
|
622
|
+
getReportCount(form) {
|
623
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/report_count", form);
|
624
|
+
}
|
648
625
|
/**
|
649
626
|
* Get your unread counts
|
650
627
|
*
|
651
628
|
* `HTTP.GET /user/unread_count`
|
652
629
|
*/
|
653
|
-
|
654
|
-
return this.
|
655
|
-
}
|
630
|
+
getUnreadCount(form) {
|
631
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/unread_count", form);
|
632
|
+
}
|
656
633
|
/**
|
657
634
|
* Verify your email
|
658
635
|
*
|
659
636
|
* `HTTP.POST /user/verify_email`
|
660
637
|
*/
|
661
|
-
|
662
|
-
return this.
|
663
|
-
}
|
638
|
+
verifyEmail(form) {
|
639
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/verify_email", form);
|
640
|
+
}
|
664
641
|
/**
|
665
642
|
* Add an admin to your site.
|
666
643
|
*
|
667
644
|
* `HTTP.POST /admin/add`
|
668
645
|
*/
|
669
|
-
|
670
|
-
return this.
|
671
|
-
}
|
646
|
+
addAdmin(form) {
|
647
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/admin/add", form);
|
648
|
+
}
|
672
649
|
/**
|
673
650
|
* Get the unread registration applications count.
|
674
651
|
*
|
675
652
|
* `HTTP.GET /admin/registration_application/count`
|
676
653
|
*/
|
677
|
-
|
678
|
-
return this.
|
679
|
-
}
|
654
|
+
getUnreadRegistrationApplicationCount(form) {
|
655
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/admin/registration_application/count", form);
|
656
|
+
}
|
680
657
|
/**
|
681
658
|
* List the registration applications.
|
682
659
|
*
|
683
660
|
* `HTTP.GET /admin/registration_application/list`
|
684
661
|
*/
|
685
|
-
|
686
|
-
return this.
|
687
|
-
}
|
662
|
+
listRegistrationApplications(form) {
|
663
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/admin/registration_application/list", form);
|
664
|
+
}
|
688
665
|
/**
|
689
666
|
* Approve a registration application
|
690
667
|
*
|
691
668
|
* `HTTP.PUT /admin/registration_application/approve`
|
692
669
|
*/
|
693
|
-
|
694
|
-
return this.
|
695
|
-
}
|
670
|
+
approveRegistrationApplication(form) {
|
671
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/admin/registration_application/approve", form);
|
672
|
+
}
|
696
673
|
/**
|
697
674
|
* Purge / Delete a person from the database.
|
698
675
|
*
|
699
676
|
* `HTTP.POST /admin/purge/person`
|
700
677
|
*/
|
701
|
-
|
702
|
-
return this.
|
703
|
-
}
|
678
|
+
purgePerson(form) {
|
679
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/admin/purge/person", form);
|
680
|
+
}
|
704
681
|
/**
|
705
682
|
* Purge / Delete a community from the database.
|
706
683
|
*
|
707
684
|
* `HTTP.POST /admin/purge/community`
|
708
685
|
*/
|
709
|
-
|
710
|
-
return this.
|
711
|
-
}
|
686
|
+
purgeCommunity(form) {
|
687
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/admin/purge/community", form);
|
688
|
+
}
|
712
689
|
/**
|
713
690
|
* Purge / Delete a post from the database.
|
714
691
|
*
|
715
692
|
* `HTTP.POST /admin/purge/post`
|
716
693
|
*/
|
717
|
-
|
718
|
-
return this.
|
719
|
-
}
|
694
|
+
purgePost(form) {
|
695
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/admin/purge/post", form);
|
696
|
+
}
|
720
697
|
/**
|
721
698
|
* Purge / Delete a comment from the database.
|
722
699
|
*
|
723
700
|
* `HTTP.POST /admin/purge/comment`
|
724
701
|
*/
|
725
|
-
|
726
|
-
return this.
|
727
|
-
}
|
702
|
+
purgeComment(form) {
|
703
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/admin/purge/comment", form);
|
704
|
+
}
|
728
705
|
/**
|
729
706
|
* Create a new custom emoji
|
730
707
|
*
|
731
708
|
* `HTTP.POST /custom_emoji`
|
732
709
|
*/
|
733
|
-
|
734
|
-
return __awaiter(this, void 0, void 0, function () {
|
735
|
-
return
|
736
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/custom_emoji", form)];
|
737
|
-
});
|
710
|
+
createCustomEmoji(form) {
|
711
|
+
return __awaiter(this, void 0, void 0, function* () {
|
712
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/custom_emoji", form);
|
738
713
|
});
|
739
|
-
}
|
714
|
+
}
|
740
715
|
/**
|
741
716
|
* Edit an existing custom emoji
|
742
717
|
*
|
743
718
|
* `HTTP.PUT /custom_emoji`
|
744
719
|
*/
|
745
|
-
|
746
|
-
return __awaiter(this, void 0, void 0, function () {
|
747
|
-
return
|
748
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/custom_emoji", form)];
|
749
|
-
});
|
720
|
+
editCustomEmoji(form) {
|
721
|
+
return __awaiter(this, void 0, void 0, function* () {
|
722
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/custom_emoji", form);
|
750
723
|
});
|
751
|
-
}
|
724
|
+
}
|
752
725
|
/**
|
753
726
|
* Delete a custom emoji
|
754
727
|
*
|
755
728
|
* `HTTP.Post /custom_emoji/delete`
|
756
729
|
*/
|
757
|
-
|
758
|
-
return __awaiter(this, void 0, void 0, function () {
|
759
|
-
return
|
760
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/custom_emoji/delete", form)];
|
761
|
-
});
|
730
|
+
deleteCustomEmoji(form) {
|
731
|
+
return __awaiter(this, void 0, void 0, function* () {
|
732
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/custom_emoji/delete", form);
|
762
733
|
});
|
763
|
-
}
|
734
|
+
}
|
764
735
|
/**
|
765
736
|
* Fetch federated instances.
|
766
737
|
*
|
767
738
|
* `HTTP.Get /federated_instances`
|
768
739
|
*/
|
769
|
-
|
770
|
-
return __awaiter(this, void 0, void 0, function () {
|
771
|
-
return
|
772
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/federated_instances", form)];
|
773
|
-
});
|
740
|
+
getFederatedInstances(form) {
|
741
|
+
return __awaiter(this, void 0, void 0, function* () {
|
742
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/federated_instances", form);
|
774
743
|
});
|
775
|
-
}
|
744
|
+
}
|
776
745
|
/**
|
777
746
|
* Upload an image to the server.
|
778
747
|
*/
|
779
|
-
|
780
|
-
var _b, _c, _d
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
return [4 /*yield*/, (0, cross_fetch_1.default)(this.pictrsUrl, {
|
796
|
-
method: HttpType.Post,
|
797
|
-
body: formData,
|
798
|
-
headers: __assign(__assign({}, this.headers), headers),
|
799
|
-
})];
|
800
|
-
case 1:
|
801
|
-
response = _g.sent();
|
802
|
-
return [4 /*yield*/, response.json()];
|
803
|
-
case 2:
|
804
|
-
responseJson = _g.sent();
|
805
|
-
if (responseJson.msg === "ok") {
|
806
|
-
_f = responseJson.files[0], hash = _f.file, deleteToken = _f.delete_token;
|
807
|
-
delete_url = "".concat(this.pictrsUrl, "/delete/").concat(deleteToken, "/").concat(hash);
|
808
|
-
url = "".concat(this.pictrsUrl, "/").concat(hash);
|
809
|
-
}
|
810
|
-
return [2 /*return*/, __assign(__assign({}, responseJson), { url: url, delete_url: delete_url })];
|
811
|
-
}
|
812
|
-
});
|
813
|
-
});
|
814
|
-
};
|
815
|
-
LemmyHttp.prototype.buildFullUrl = function (endpoint) {
|
816
|
-
return "".concat(this.apiUrl).concat(endpoint);
|
817
|
-
};
|
818
|
-
LemmyHttp.prototype.wrapper = function (type_, endpoint, form) {
|
819
|
-
var _a;
|
820
|
-
return __awaiter(this, void 0, void 0, function () {
|
821
|
-
var response, getUrl, json;
|
822
|
-
return __generator(this, function (_b) {
|
823
|
-
switch (_b.label) {
|
824
|
-
case 0:
|
825
|
-
if (!(type_ === HttpType.Get)) return [3 /*break*/, 2];
|
826
|
-
getUrl = "".concat(this.buildFullUrl(endpoint), "?").concat(encodeGetParams(form));
|
827
|
-
return [4 /*yield*/, (0, cross_fetch_1.default)(getUrl, {
|
828
|
-
method: HttpType.Get,
|
829
|
-
headers: this.headers,
|
830
|
-
})];
|
831
|
-
case 1:
|
832
|
-
response = _b.sent();
|
833
|
-
return [3 /*break*/, 4];
|
834
|
-
case 2: return [4 /*yield*/, (0, cross_fetch_1.default)(this.buildFullUrl(endpoint), {
|
835
|
-
method: type_,
|
836
|
-
headers: __assign({ "Content-Type": "application/json" }, this.headers),
|
837
|
-
body: JSON.stringify(form),
|
838
|
-
})];
|
839
|
-
case 3:
|
840
|
-
response = _b.sent();
|
841
|
-
_b.label = 4;
|
842
|
-
case 4: return [4 /*yield*/, response.json()];
|
843
|
-
case 5:
|
844
|
-
json = _b.sent();
|
845
|
-
if (!response.ok) {
|
846
|
-
throw (_a = json["error"]) !== null && _a !== void 0 ? _a : response.statusText;
|
847
|
-
}
|
848
|
-
else {
|
849
|
-
return [2 /*return*/, json];
|
850
|
-
}
|
851
|
-
return [2 /*return*/];
|
852
|
-
}
|
748
|
+
uploadImage({ image, auth, }) {
|
749
|
+
var _a, _b, _c, _d;
|
750
|
+
return __awaiter(this, void 0, void 0, function* () {
|
751
|
+
const formData = createFormData(image);
|
752
|
+
// If jwt cookie not already set by browser, set it with passed in auth
|
753
|
+
const headers = {};
|
754
|
+
if (!((_b = (_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) === null || _a === void 0 ? void 0 : _a.cookie) === null || _b === void 0 ? void 0 : _b.includes("jwt=")) &&
|
755
|
+
!((_d = (_c = __classPrivateFieldGet(this, _LemmyHttp_headers, "f")) === null || _c === void 0 ? void 0 : _c.Cookie) === null || _d === void 0 ? void 0 : _d.includes("jwt="))) {
|
756
|
+
headers.Cookie = `jwt=${auth}`;
|
757
|
+
}
|
758
|
+
let url = undefined;
|
759
|
+
let delete_url = undefined;
|
760
|
+
const response = yield (0, cross_fetch_1.default)(__classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f"), {
|
761
|
+
method: HttpType.Post,
|
762
|
+
body: formData,
|
763
|
+
headers: Object.assign(Object.assign({}, __classPrivateFieldGet(this, _LemmyHttp_headers, "f")), headers),
|
853
764
|
});
|
765
|
+
const responseJson = yield response.json();
|
766
|
+
if (responseJson.msg === "ok") {
|
767
|
+
const { file: hash, delete_token: deleteToken } = responseJson.files[0];
|
768
|
+
delete_url = `${__classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f")}/delete/${deleteToken}/${hash}`;
|
769
|
+
url = `${__classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f")}/${hash}`;
|
770
|
+
}
|
771
|
+
return Object.assign(Object.assign({}, responseJson), { url,
|
772
|
+
delete_url });
|
854
773
|
});
|
855
|
-
}
|
856
|
-
|
857
|
-
}());
|
774
|
+
}
|
775
|
+
}
|
858
776
|
exports.LemmyHttp = LemmyHttp;
|
777
|
+
_LemmyHttp_apiUrl = new WeakMap(), _LemmyHttp_headers = new WeakMap(), _LemmyHttp_pictrsUrl = new WeakMap(), _LemmyHttp_instances = new WeakSet(), _LemmyHttp_buildFullUrl = function _LemmyHttp_buildFullUrl(endpoint) {
|
778
|
+
return `${__classPrivateFieldGet(this, _LemmyHttp_apiUrl, "f")}${endpoint}`;
|
779
|
+
}, _LemmyHttp_wrapper = function _LemmyHttp_wrapper(type_, endpoint, form) {
|
780
|
+
var _a;
|
781
|
+
return __awaiter(this, void 0, void 0, function* () {
|
782
|
+
let response;
|
783
|
+
if (type_ === HttpType.Get) {
|
784
|
+
const getUrl = `${__classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_buildFullUrl).call(this, endpoint)}?${encodeGetParams(form)}`;
|
785
|
+
response = yield (0, cross_fetch_1.default)(getUrl, {
|
786
|
+
method: HttpType.Get,
|
787
|
+
headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f"),
|
788
|
+
});
|
789
|
+
}
|
790
|
+
else {
|
791
|
+
response = yield (0, cross_fetch_1.default)(__classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_buildFullUrl).call(this, endpoint), {
|
792
|
+
method: type_,
|
793
|
+
headers: Object.assign({ "Content-Type": "application/json" }, __classPrivateFieldGet(this, _LemmyHttp_headers, "f")),
|
794
|
+
body: JSON.stringify(form),
|
795
|
+
});
|
796
|
+
}
|
797
|
+
const json = yield response.json();
|
798
|
+
if (!response.ok) {
|
799
|
+
throw (_a = json["error"]) !== null && _a !== void 0 ? _a : response.statusText;
|
800
|
+
}
|
801
|
+
else {
|
802
|
+
return json;
|
803
|
+
}
|
804
|
+
});
|
805
|
+
};
|
859
806
|
function encodeGetParams(p) {
|
860
807
|
return Object.entries(p)
|
861
|
-
.filter(
|
862
|
-
.map(
|
808
|
+
.filter(kv => !!kv[1])
|
809
|
+
.map(kv => kv.map(encodeURIComponent).join("="))
|
863
810
|
.join("&");
|
864
811
|
}
|
865
812
|
function createFormData(image) {
|
866
|
-
|
813
|
+
let formData = new form_data_1.default();
|
867
814
|
if (image.constructor.name === "File") {
|
868
815
|
formData.append("images[]", image);
|
869
816
|
}
|