comty.js 0.63.0 → 0.64.0

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.
@@ -2,87 +2,87 @@
2
2
  var _withSettings = require('../../helpers/withSettings'); var _withSettings2 = _interopRequireDefault(_withSettings);
3
3
 
4
4
  class FeedModel {
5
- /**
6
- * Retrieves music feed with optional trimming and limiting.
7
- *
8
- * @param {Object} options - Optional parameters for trimming and limiting the feed
9
- * @param {number} options.trim - The number of items to trim from the feed
10
- * @param {number} options.limit - The maximum number of items to fetch from the feed
11
- * @return {Promise<Object>} The music feed data
12
- */
13
- static async getMusicFeed({ trim, limit } = {}) {
14
- const { data } = await _request2.default.call(void 0, {
15
- method: "GET",
16
- url: `/music/feed/my`,
17
- params: {
18
- trim: _nullishCoalesce(trim, () => ( 0)),
19
- limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
20
- }
21
- })
5
+ /**
6
+ * Retrieves music feed with optional trimming and limiting.
7
+ *
8
+ * @param {Object} options - Optional parameters for trimming and limiting the feed
9
+ * @param {number} options.page - The number of items to page from the feed
10
+ * @param {number} options.limit - The maximum number of items to fetch from the feed
11
+ * @return {Promise<Object>} The music feed data
12
+ */
13
+ static async getMusicFeed({ page, limit } = {}) {
14
+ const { data } = await _request2.default.call(void 0, {
15
+ method: "GET",
16
+ url: `/music/feed/my`,
17
+ params: {
18
+ page: _nullishCoalesce(page, () => ( 0)),
19
+ limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
20
+ },
21
+ })
22
22
 
23
- return data
24
- }
23
+ return data
24
+ }
25
25
 
26
- /**
27
- * Retrieves the global music feed with optional trimming and limiting.
28
- *
29
- * @param {Object} options - An object containing optional parameters:
30
- * @param {number} options.trim - The number of items to trim from the feed
31
- * @param {number} options.limit - The maximum number of items to fetch from the feed
32
- * @return {Promise<Object>} The global music feed data
33
- */
34
- static async getGlobalMusicFeed({ trim, limit } = {}) {
35
- const { data } = await _request2.default.call(void 0, {
36
- method: "GET",
37
- url: `/music/feed`,
38
- params: {
39
- trim: _nullishCoalesce(trim, () => ( 0)),
40
- limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
41
- }
42
- })
26
+ /**
27
+ * Retrieves the global music feed with optional trimming and limiting.
28
+ *
29
+ * @param {Object} options - An object containing optional parameters:
30
+ * @param {number} options.page - The number of items to page from the feed
31
+ * @param {number} options.limit - The maximum number of items to fetch from the feed
32
+ * @return {Promise<Object>} The global music feed data
33
+ */
34
+ static async getGlobalMusicFeed({ page, limit } = {}) {
35
+ const { data } = await _request2.default.call(void 0, {
36
+ method: "GET",
37
+ url: `/music/feed`,
38
+ params: {
39
+ page: _nullishCoalesce(page, () => ( 0)),
40
+ limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
41
+ },
42
+ })
43
43
 
44
- return data
45
- }
44
+ return data
45
+ }
46
46
 
47
- /**
48
- * Retrieves the timeline feed with optional trimming and limiting.
49
- *
50
- * @param {object} options - Object containing trim and limit properties
51
- * @param {number} options.trim - The number of feed items to trim
52
- * @param {number} options.limit - The maximum number of feed items to retrieve
53
- * @return {Promise<object>} The timeline feed data
54
- */
55
- static async getTimelineFeed({ trim, limit } = {}) {
56
- const { data } = await _request2.default.call(void 0, {
57
- method: "GET",
58
- url: `/posts/feed/timeline`,
59
- params: {
60
- trim: _nullishCoalesce(trim, () => ( 0)),
61
- limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
62
- }
63
- })
47
+ /**
48
+ * Retrieves the timeline feed with optional trimming and limiting.
49
+ *
50
+ * @param {object} options - Object containing page and limit properties
51
+ * @param {number} options.page - The number of feed items to page
52
+ * @param {number} options.limit - The maximum number of feed items to retrieve
53
+ * @return {Promise<object>} The timeline feed data
54
+ */
55
+ static async getTimelineFeed({ page, limit } = {}) {
56
+ const { data } = await _request2.default.call(void 0, {
57
+ method: "GET",
58
+ url: `/posts/feed/timeline`,
59
+ params: {
60
+ page: _nullishCoalesce(page, () => ( 0)),
61
+ limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
62
+ },
63
+ })
64
64
 
65
- return data
66
- }
65
+ return data
66
+ }
67
67
 
68
- /**
69
- * Retrieves the posts feed with options to trim and limit the results.
70
- *
71
- * @param {Object} options - An object containing optional parameters for trimming and limiting the feed.
72
- * @param {number} options.trim - The number of characters to trim the feed content.
73
- * @param {number} options.limit - The maximum number of posts to fetch from the feed.
74
- * @return {Promise<Object>} The posts feed data.
75
- */
76
- static async getGlobalTimelineFeed({ trim, limit } = {}) {
77
- const { data } = await _request2.default.call(void 0, {
78
- method: "GET",
79
- url: `/posts/feed/global`,
80
- params: {
81
- trim: _nullishCoalesce(trim, () => ( 0)),
82
- limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
83
- }
84
- })
68
+ /**
69
+ * Retrieves the posts feed with options to page and limit the results.
70
+ *
71
+ * @param {Object} options - An object containing optional parameters for trimming and limiting the feed.
72
+ * @param {number} options.page - The number of characters to page the feed content.
73
+ * @param {number} options.limit - The maximum number of posts to fetch from the feed.
74
+ * @return {Promise<Object>} The posts feed data.
75
+ */
76
+ static async getGlobalTimelineFeed({ page, limit } = {}) {
77
+ const { data } = await _request2.default.call(void 0, {
78
+ method: "GET",
79
+ url: `/posts/feed/global`,
80
+ params: {
81
+ page: _nullishCoalesce(page, () => ( 0)),
82
+ limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
83
+ },
84
+ })
85
85
 
86
- return data
87
- }
88
- } exports.default = FeedModel;
86
+ return data
87
+ }
88
+ } exports.default = FeedModel;
@@ -2,344 +2,344 @@
2
2
  var _withSettings = require('../../helpers/withSettings'); var _withSettings2 = _interopRequireDefault(_withSettings);
3
3
 
4
4
  class Post {
5
- /**
6
- * Retrieves the maximum length allowed for the post text.
7
- *
8
- * @return {number} The maximum length allowed for the post text.
9
- */
10
- static get maxPostTextLength() {
11
- return 3200
12
- }
13
-
14
- /**
15
- * Returns the maximum length allowed for a comment.
16
- *
17
- * @return {number} The maximum length allowed for a comment.
18
- */
19
- static get maxCommentLength() {
20
- return 1200
21
- }
22
-
23
- /**
24
- * Retrieves the posting policy from the server.
25
- *
26
- * @return {Promise<Object>} The posting policy data.
27
- */
28
- static async getPostingPolicy() {
29
- const { data } = await _request2.default.call(void 0, {
30
- method: "GET",
31
- url: "/posting_policy",
32
- })
33
-
34
- return data
35
- }
36
-
37
- /**
38
- * Retrieves the data of a post by its ID.
39
- *
40
- * @param {Object} options - The options for retrieving the post.
41
- * @param {string} options.post_id - The ID of the post to retrieve.
42
- * @throws {Error} If the post_id is not provided.
43
- * @return {Promise<Object>} The data of the post.
44
- */
45
- static async post({ post_id }) {
46
- if (!post_id) {
47
- throw new Error("Post ID is required")
48
- }
49
-
50
- const { data } = await _request2.default.call(void 0, {
51
- method: "GET",
52
- url: `/posts/${post_id}/data`,
53
- })
54
-
55
- return data
56
- }
57
-
58
- static __initStatic() {this.getPost = Post.post}
59
-
60
- /**
61
- * Retrieves the replies of a post by its ID.
62
- *
63
- * @param {Object} options - The options for retrieving the replies.
64
- * @param {string} options.post_id - The ID of the post to retrieve replies for.
65
- * @param {number} [options.trim=0] - The number of characters to trim the reply content.
66
- * @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of replies to fetch.
67
- * @throws {Error} If the post_id is not provided.
68
- * @return {Promise<Object>} The data of the replies.
69
- */
70
- static async replies({ post_id, trim, limit }) {
71
- if (!post_id) {
72
- throw new Error("Post ID is required")
73
- }
74
-
75
- const { data } = await _request2.default.call(void 0, {
76
- method: "GET",
77
- url: `/posts/${post_id}/replies`,
78
- params: {
79
- trim: _nullishCoalesce(trim, () => ( 0)),
80
- limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
81
- }
82
- })
83
-
84
- return data
85
- }
86
-
87
- /**
88
- * Retrieves the saved posts with optional trimming and limiting.
89
- *
90
- * @param {Object} options - The options for retrieving the saved posts.
91
- * @param {number} [options.trim=0] - The number of posts to trim from the result.
92
- * @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
93
- * @return {Promise<Object>} The data of the saved posts.
94
- */
95
- static async getSavedPosts({ trim, limit }) {
96
- const { data } = await _request2.default.call(void 0, {
97
- method: "GET",
98
- url: `/posts/saved`,
99
- params: {
100
- trim: _nullishCoalesce(trim, () => ( 0)),
101
- limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
102
- }
103
- })
104
-
105
- return data
106
- }
107
-
108
- /**
109
- * Retrieves the liked posts with optional trimming and limiting.
110
- *
111
- * @param {number} trim - The number of characters to trim the post content.
112
- * @param {number} limit - The maximum number of liked posts to fetch.
113
- * @return {Promise<Object>} The data of the liked posts.
114
- */
115
- static async getLikedPosts({ trim, limit }) {
116
- const { data } = await _request2.default.call(void 0, {
117
- method: "GET",
118
- url: `/posts/liked`,
119
- params: {
120
- trim: _nullishCoalesce(trim, () => ( 0)),
121
- limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
122
- }
123
- })
124
-
125
- return data
126
- }
127
-
128
- /**
129
- * Retrieves the posts of a user with optional trimming and limiting.
130
- *
131
- * @param {Object} options - The options for retrieving the user's posts.
132
- * @param {string} options.user_id - The ID of the user whose posts to retrieve. If not provided, the current user's ID will be used.
133
- * @param {number} [options.trim=0] - The number of characters to trim the post content.
134
- * @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
135
- * @return {Promise<Object>} The data of the user's posts.
136
- */
137
- static async getUserPosts({ user_id, trim, limit }) {
138
- if (!user_id) {
139
- // use current user_id
140
- user_id = _optionalChain([app, 'access', _ => _.userData, 'optionalAccess', _2 => _2._id])
141
- }
142
-
143
- const { data } = await _request2.default.call(void 0, {
144
- method: "GET",
145
- url: `/posts/user/${user_id}`,
146
- params: {
147
- trim: _nullishCoalesce(trim, () => ( 0)),
148
- limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
149
- }
150
- })
151
-
152
- return data
153
- }
154
-
155
- /**
156
- * Toggles the like status of a post.
157
- *
158
- * @param {Object} options - The options for toggling the like status.
159
- * @param {string} options.post_id - The ID of the post to toggle the like status.
160
- * @throws {Error} If the post_id is not provided.
161
- * @return {Promise<Object>} The response data after toggling the like status.
162
- */
163
- static async toggleLike({ post_id }) {
164
- if (!post_id) {
165
- throw new Error("Post ID is required")
166
- }
167
-
168
- const { data } = await _request2.default.call(void 0, {
169
- method: "POST",
170
- url: `/posts/${post_id}/toggle_like`,
171
- })
172
-
173
- return data
174
- }
175
-
176
- /**
177
- * Toggles the save status of a post.
178
- *
179
- * @param {string} post_id - The ID of the post to toggle the save status.
180
- * @return {Promise<Object>} The response data after toggling the save status.
181
- */
182
- static async toggleSave({ post_id }) {
183
- if (!post_id) {
184
- throw new Error("Post ID is required")
185
- }
186
-
187
- const { data } = await _request2.default.call(void 0, {
188
- method: "POST",
189
- url: `/posts/${post_id}/toggle_save`,
190
- })
191
-
192
- return data
193
- }
194
-
195
- /**
196
- * Creates a new post with the given payload.
197
- *
198
- * @param {Object} payload - The data to create the post with.
199
- * @return {Promise<Object>} The response data after creating the post.
200
- */
201
- static async create(payload) {
202
- const { data } = await _request2.default.call(void 0, {
203
- method: "POST",
204
- url: `/posts/new`,
205
- data: payload,
206
- })
207
-
208
- return data
209
- }
210
-
211
- static __initStatic2() {this.createPost = Post.create}
212
-
213
- /**
214
- * Updates a post with the given post ID and update payload.
215
- *
216
- * @param {string} post_id - The ID of the post to update.
217
- * @param {Object} update - The data to update the post with.
218
- * @throws {Error} If the post_id is not provided.
219
- * @return {Promise<Object>} The response data after updating the post.
220
- */
221
- static async update(post_id, update) {
222
- if (!post_id) {
223
- throw new Error("Post ID is required")
224
- }
225
-
226
- const { data } = await _request2.default.call(void 0, {
227
- method: "PUT",
228
- url: `/posts/${post_id}/update`,
229
- data: update,
230
- })
231
-
232
- return data
233
- }
234
-
235
- static __initStatic3() {this.updatePost = Post.update}
236
-
237
- /**
238
- * Deletes a post with the given post ID.
239
- *
240
- * @param {string} post_id - The ID of the post to delete.
241
- * @return {Object} The response data after deleting the post.
242
- */
243
- static async delete({ post_id }) {
244
- if (!post_id) {
245
- throw new Error("Post ID is required")
246
- }
247
-
248
- const { data } = await _request2.default.call(void 0, {
249
- method: "DELETE",
250
- url: `/posts/${post_id}`,
251
- })
252
-
253
- return data
254
- }
255
-
256
- static __initStatic4() {this.deletePost = Post.delete}
257
-
258
- /**
259
- * Votes for a poll with the given post ID and option ID.
260
- *
261
- * @param {Object} options - The options for voting.
262
- * @param {string} options.post_id - The ID of the post to vote for.
263
- * @param {string} options.option_id - The ID of the option to vote for.
264
- * @throws {Error} If the post_id or option_id is not provided.
265
- * @return {Promise<Object>} The response data after voting.
266
- */
267
- static async votePoll({ post_id, option_id }) {
268
- if (!post_id) {
269
- throw new Error("post_id is required")
270
- }
271
-
272
- if (!option_id) {
273
- throw new Error("option_id is required")
274
- }
275
-
276
- const { data } = await _request2.default.call(void 0, {
277
- method: "POST",
278
- url: `/posts/${post_id}/vote_poll/${option_id}`,
279
- })
280
-
281
- return data
282
- }
283
-
284
- /**
285
- * Deletes a vote for a poll with the given post ID and option ID.
286
- *
287
- * @param {Object} options - The options for deleting a vote.
288
- * @param {string} options.post_id - The ID of the post to delete the vote from.
289
- * @param {string} options.option_id - The ID of the option to delete the vote from.
290
- * @throws {Error} If the post_id or option_id is not provided.
291
- * @return {Promise<Object>} The response data after deleting the vote.
292
- */
293
- static async deleteVotePoll({ post_id, option_id }) {
294
- if (!post_id) {
295
- throw new Error("post_id is required")
296
- }
297
-
298
- if (!option_id) {
299
- throw new Error("option_id is required")
300
- }
301
-
302
- const { data } = await _request2.default.call(void 0, {
303
- method: "DELETE",
304
- url: `/posts/${post_id}/vote_poll/${option_id}`,
305
- })
306
-
307
- return data
308
- }
309
-
310
- /**
311
- * Retrieves the trending hashtags and their counts.
312
- *
313
- * @return {Promise<Object[]>} An array of objects with two properties: "hashtag" and "count".
314
- */
315
- static async getTrendings() {
316
- const { data } = await _request2.default.call(void 0, {
317
- method: "GET",
318
- url: `/posts/trendings`,
319
- })
320
-
321
- return data
322
- }
323
-
324
- /**
325
- * Retrieves the trending posts for a specific hashtag with optional trimming and limiting.
326
- *
327
- * @param {Object} options - The options for retrieving trending posts.
328
- * @param {string} options.trending - The hashtag to retrieve trending posts for.
329
- * @param {number} [options.trim=0] - The number of characters to trim the post content.
330
- * @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
331
- * @return {Promise<Object[]>} An array of posts that are trending for the given hashtag.
332
- */
333
- static async getTrending({ trending, trim, limit } = {}) {
334
- const { data } = await _request2.default.call(void 0, {
335
- method: "GET",
336
- url: `/posts/trending/${trending}`,
337
- params: {
338
- trim: _nullishCoalesce(trim, () => ( 0)),
339
- limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
340
- }
341
- })
342
-
343
- return data
344
- }
345
- } Post.__initStatic(); Post.__initStatic2(); Post.__initStatic3(); Post.__initStatic4(); exports.default = Post;
5
+ /**
6
+ * Retrieves the maximum length allowed for the post text.
7
+ *
8
+ * @return {number} The maximum length allowed for the post text.
9
+ */
10
+ static get maxPostTextLength() {
11
+ return 3200
12
+ }
13
+
14
+ /**
15
+ * Returns the maximum length allowed for a comment.
16
+ *
17
+ * @return {number} The maximum length allowed for a comment.
18
+ */
19
+ static get maxCommentLength() {
20
+ return 1200
21
+ }
22
+
23
+ /**
24
+ * Retrieves the posting policy from the server.
25
+ *
26
+ * @return {Promise<Object>} The posting policy data.
27
+ */
28
+ static async getPostingPolicy() {
29
+ const { data } = await _request2.default.call(void 0, {
30
+ method: "GET",
31
+ url: "/posting_policy",
32
+ })
33
+
34
+ return data
35
+ }
36
+
37
+ /**
38
+ * Retrieves the data of a post by its ID.
39
+ *
40
+ * @param {Object} options - The options for retrieving the post.
41
+ * @param {string} options.post_id - The ID of the post to retrieve.
42
+ * @throws {Error} If the post_id is not provided.
43
+ * @return {Promise<Object>} The data of the post.
44
+ */
45
+ static async post({ post_id }) {
46
+ if (!post_id) {
47
+ throw new Error("Post ID is required")
48
+ }
49
+
50
+ const { data } = await _request2.default.call(void 0, {
51
+ method: "GET",
52
+ url: `/posts/${post_id}/data`,
53
+ })
54
+
55
+ return data
56
+ }
57
+
58
+ static __initStatic() {this.getPost = Post.post}
59
+
60
+ /**
61
+ * Retrieves the replies of a post by its ID.
62
+ *
63
+ * @param {Object} options - The options for retrieving the replies.
64
+ * @param {string} options.post_id - The ID of the post to retrieve replies for.
65
+ * @param {number} [options.page=0] - The number of characters to page the reply content.
66
+ * @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of replies to fetch.
67
+ * @throws {Error} If the post_id is not provided.
68
+ * @return {Promise<Object>} The data of the replies.
69
+ */
70
+ static async replies({ post_id, page, limit }) {
71
+ if (!post_id) {
72
+ throw new Error("Post ID is required")
73
+ }
74
+
75
+ const { data } = await _request2.default.call(void 0, {
76
+ method: "GET",
77
+ url: `/posts/${post_id}/replies`,
78
+ params: {
79
+ page: _nullishCoalesce(page, () => ( 0)),
80
+ limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
81
+ },
82
+ })
83
+
84
+ return data
85
+ }
86
+
87
+ /**
88
+ * Retrieves the saved posts with optional trimming and limiting.
89
+ *
90
+ * @param {Object} options - The options for retrieving the saved posts.
91
+ * @param {number} [options.page=0] - The number of posts to page from the result.
92
+ * @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
93
+ * @return {Promise<Object>} The data of the saved posts.
94
+ */
95
+ static async getSavedPosts({ page, limit }) {
96
+ const { data } = await _request2.default.call(void 0, {
97
+ method: "GET",
98
+ url: `/posts/saved`,
99
+ params: {
100
+ page: _nullishCoalesce(page, () => ( 0)),
101
+ limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
102
+ },
103
+ })
104
+
105
+ return data
106
+ }
107
+
108
+ /**
109
+ * Retrieves the liked posts with optional trimming and limiting.
110
+ *
111
+ * @param {number} page - The number of characters to page the post content.
112
+ * @param {number} limit - The maximum number of liked posts to fetch.
113
+ * @return {Promise<Object>} The data of the liked posts.
114
+ */
115
+ static async getLikedPosts({ page, limit }) {
116
+ const { data } = await _request2.default.call(void 0, {
117
+ method: "GET",
118
+ url: `/posts/liked`,
119
+ params: {
120
+ page: _nullishCoalesce(page, () => ( 0)),
121
+ limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
122
+ },
123
+ })
124
+
125
+ return data
126
+ }
127
+
128
+ /**
129
+ * Retrieves the posts of a user with optional trimming and limiting.
130
+ *
131
+ * @param {Object} options - The options for retrieving the user's posts.
132
+ * @param {string} options.user_id - The ID of the user whose posts to retrieve. If not provided, the current user's ID will be used.
133
+ * @param {number} [options.page=0] - The number of characters to page the post content.
134
+ * @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
135
+ * @return {Promise<Object>} The data of the user's posts.
136
+ */
137
+ static async getUserPosts({ user_id, page, limit }) {
138
+ if (!user_id) {
139
+ // use current user_id
140
+ user_id = _optionalChain([app, 'access', _ => _.userData, 'optionalAccess', _2 => _2._id])
141
+ }
142
+
143
+ const { data } = await _request2.default.call(void 0, {
144
+ method: "GET",
145
+ url: `/posts/user/${user_id}`,
146
+ params: {
147
+ page: _nullishCoalesce(page, () => ( 0)),
148
+ limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
149
+ },
150
+ })
151
+
152
+ return data
153
+ }
154
+
155
+ /**
156
+ * Toggles the like status of a post.
157
+ *
158
+ * @param {Object} options - The options for toggling the like status.
159
+ * @param {string} options.post_id - The ID of the post to toggle the like status.
160
+ * @throws {Error} If the post_id is not provided.
161
+ * @return {Promise<Object>} The response data after toggling the like status.
162
+ */
163
+ static async toggleLike({ post_id }) {
164
+ if (!post_id) {
165
+ throw new Error("Post ID is required")
166
+ }
167
+
168
+ const { data } = await _request2.default.call(void 0, {
169
+ method: "POST",
170
+ url: `/posts/${post_id}/toggle_like`,
171
+ })
172
+
173
+ return data
174
+ }
175
+
176
+ /**
177
+ * Toggles the save status of a post.
178
+ *
179
+ * @param {string} post_id - The ID of the post to toggle the save status.
180
+ * @return {Promise<Object>} The response data after toggling the save status.
181
+ */
182
+ static async toggleSave({ post_id }) {
183
+ if (!post_id) {
184
+ throw new Error("Post ID is required")
185
+ }
186
+
187
+ const { data } = await _request2.default.call(void 0, {
188
+ method: "POST",
189
+ url: `/posts/${post_id}/toggle_save`,
190
+ })
191
+
192
+ return data
193
+ }
194
+
195
+ /**
196
+ * Creates a new post with the given payload.
197
+ *
198
+ * @param {Object} payload - The data to create the post with.
199
+ * @return {Promise<Object>} The response data after creating the post.
200
+ */
201
+ static async create(payload) {
202
+ const { data } = await _request2.default.call(void 0, {
203
+ method: "POST",
204
+ url: `/posts/new`,
205
+ data: payload,
206
+ })
207
+
208
+ return data
209
+ }
210
+
211
+ static __initStatic2() {this.createPost = Post.create}
212
+
213
+ /**
214
+ * Updates a post with the given post ID and update payload.
215
+ *
216
+ * @param {string} post_id - The ID of the post to update.
217
+ * @param {Object} update - The data to update the post with.
218
+ * @throws {Error} If the post_id is not provided.
219
+ * @return {Promise<Object>} The response data after updating the post.
220
+ */
221
+ static async update(post_id, update) {
222
+ if (!post_id) {
223
+ throw new Error("Post ID is required")
224
+ }
225
+
226
+ const { data } = await _request2.default.call(void 0, {
227
+ method: "PUT",
228
+ url: `/posts/${post_id}/update`,
229
+ data: update,
230
+ })
231
+
232
+ return data
233
+ }
234
+
235
+ static __initStatic3() {this.updatePost = Post.update}
236
+
237
+ /**
238
+ * Deletes a post with the given post ID.
239
+ *
240
+ * @param {string} post_id - The ID of the post to delete.
241
+ * @return {Object} The response data after deleting the post.
242
+ */
243
+ static async delete({ post_id }) {
244
+ if (!post_id) {
245
+ throw new Error("Post ID is required")
246
+ }
247
+
248
+ const { data } = await _request2.default.call(void 0, {
249
+ method: "DELETE",
250
+ url: `/posts/${post_id}`,
251
+ })
252
+
253
+ return data
254
+ }
255
+
256
+ static __initStatic4() {this.deletePost = Post.delete}
257
+
258
+ /**
259
+ * Votes for a poll with the given post ID and option ID.
260
+ *
261
+ * @param {Object} options - The options for voting.
262
+ * @param {string} options.post_id - The ID of the post to vote for.
263
+ * @param {string} options.option_id - The ID of the option to vote for.
264
+ * @throws {Error} If the post_id or option_id is not provided.
265
+ * @return {Promise<Object>} The response data after voting.
266
+ */
267
+ static async votePoll({ post_id, option_id }) {
268
+ if (!post_id) {
269
+ throw new Error("post_id is required")
270
+ }
271
+
272
+ if (!option_id) {
273
+ throw new Error("option_id is required")
274
+ }
275
+
276
+ const { data } = await _request2.default.call(void 0, {
277
+ method: "POST",
278
+ url: `/posts/${post_id}/vote_poll/${option_id}`,
279
+ })
280
+
281
+ return data
282
+ }
283
+
284
+ /**
285
+ * Deletes a vote for a poll with the given post ID and option ID.
286
+ *
287
+ * @param {Object} options - The options for deleting a vote.
288
+ * @param {string} options.post_id - The ID of the post to delete the vote from.
289
+ * @param {string} options.option_id - The ID of the option to delete the vote from.
290
+ * @throws {Error} If the post_id or option_id is not provided.
291
+ * @return {Promise<Object>} The response data after deleting the vote.
292
+ */
293
+ static async deleteVotePoll({ post_id, option_id }) {
294
+ if (!post_id) {
295
+ throw new Error("post_id is required")
296
+ }
297
+
298
+ if (!option_id) {
299
+ throw new Error("option_id is required")
300
+ }
301
+
302
+ const { data } = await _request2.default.call(void 0, {
303
+ method: "DELETE",
304
+ url: `/posts/${post_id}/vote_poll/${option_id}`,
305
+ })
306
+
307
+ return data
308
+ }
309
+
310
+ /**
311
+ * Retrieves the trending hashtags and their counts.
312
+ *
313
+ * @return {Promise<Object[]>} An array of objects with two properties: "hashtag" and "count".
314
+ */
315
+ static async getTrendings() {
316
+ const { data } = await _request2.default.call(void 0, {
317
+ method: "GET",
318
+ url: `/posts/trendings`,
319
+ })
320
+
321
+ return data
322
+ }
323
+
324
+ /**
325
+ * Retrieves the trending posts for a specific hashtag with optional trimming and limiting.
326
+ *
327
+ * @param {Object} options - The options for retrieving trending posts.
328
+ * @param {string} options.trending - The hashtag to retrieve trending posts for.
329
+ * @param {number} [options.page=0] - The number of characters to page the post content.
330
+ * @param {number} [options.limit=Settings.get("feed_max_fetch")] - The maximum number of posts to fetch.
331
+ * @return {Promise<Object[]>} An array of posts that are trending for the given hashtag.
332
+ */
333
+ static async getTrending({ trending, page, limit } = {}) {
334
+ const { data } = await _request2.default.call(void 0, {
335
+ method: "GET",
336
+ url: `/posts/trending/${trending}`,
337
+ params: {
338
+ page: _nullishCoalesce(page, () => ( 0)),
339
+ limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
340
+ },
341
+ })
342
+
343
+ return data
344
+ }
345
+ } Post.__initStatic(); Post.__initStatic2(); Post.__initStatic3(); Post.__initStatic4(); exports.default = Post;
package/dist/remotes.js CHANGED
@@ -12,10 +12,6 @@ exports. default = {
12
12
  path: "/posts",
13
13
  ng: true,
14
14
  },
15
- {
16
- namespace: "main",
17
- path: "/main",
18
- },
19
15
  {
20
16
  namespace: "notifications",
21
17
  path: "/notifications",
@@ -24,13 +20,5 @@ exports. default = {
24
20
  namespace: "chats",
25
21
  path: "/chats",
26
22
  },
27
- {
28
- namespace: "music",
29
- path: "/music",
30
- },
31
- // {
32
- // namespace: "payments",
33
- // path: "/payments",
34
- // }
35
23
  ],
36
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comty.js",
3
- "version": "0.63.0",
3
+ "version": "0.64.0",
4
4
  "main": "./dist/index.js",
5
5
  "description": "Official Comty API for JavaScript",
6
6
  "homepage": "https://github.com/ragestudio/comty.js",
@@ -18,11 +18,11 @@
18
18
  "js-cookie": "^3.0.5",
19
19
  "jsonwebtoken": "^9.0.0",
20
20
  "jwt-decode": "^4.0.0",
21
- "linebridge-client": "^1.1.0",
21
+ "linebridge-client": "^1.1.1",
22
22
  "luxon": "^3.6.0",
23
23
  "socket.io-client": "^4.8.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@ragestudio/hermes": "^1.0.0"
26
+ "@ragestudio/hermes": "^1.0.1"
27
27
  }
28
28
  }