emusks 2.0.3 → 2.0.5

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.
@@ -1,131 +1,129 @@
1
- export default (client) => ({
2
- async inbox(params = {}) {
3
- const res = await client.v1_1("dm/inbox_initial_state", { params });
4
- return await res.json();
5
- },
6
-
7
- async conversation(conversationId, params = {}) {
8
- const res = await client.v1_1("dm/conversation", {
9
- params: { id: conversationId, ...params },
10
- });
11
- return await res.json();
12
- },
13
-
14
- async search(query, opts = {}) {
15
- return await client.graphql("DmAllSearchSlice", {
16
- variables: {
17
- query,
18
- count: opts.count || 20,
19
- cursor: opts.cursor,
20
- ...opts.variables,
21
- },
22
- });
23
- },
24
-
25
- async searchGroups(query, opts = {}) {
26
- return await client.graphql("DmGroupSearchSlice", {
27
- variables: {
28
- query,
29
- count: opts.count || 20,
30
- cursor: opts.cursor,
31
- ...opts.variables,
32
- },
33
- });
34
- },
35
-
36
- async searchPeople(query, opts = {}) {
37
- return await client.graphql("DmPeopleSearchSlice", {
38
- variables: {
39
- query,
40
- count: opts.count || 20,
41
- cursor: opts.cursor,
42
- ...opts.variables,
43
- },
44
- });
45
- },
46
-
47
- async block(userId) {
48
- return await client.graphql("dmBlockUser", {
49
- body: { variables: { user_id: userId } },
50
- });
51
- },
52
-
53
- async unblock(userId) {
54
- return await client.graphql("dmUnblockUser", {
55
- body: { variables: { user_id: userId } },
56
- });
57
- },
58
-
59
- async deleteConversations(conversationIds) {
60
- const ids = Array.isArray(conversationIds) ? conversationIds : [conversationIds];
61
- const res = await client.v1_1("dm/conversation/bulk_delete", {
62
- body: JSON.stringify({ conversation_ids: ids }),
63
- });
64
- return await res.json();
65
- },
66
-
67
- async updateLastSeen(eventId) {
68
- const res = await client.v1_1("dm/update_last_seen_event_id", {
69
- body: JSON.stringify({ last_seen_event_id: eventId, trusted_last_seen_event_id: eventId }),
70
- });
71
- return await res.json();
72
- },
73
-
74
- async muted(opts = {}) {
75
- return await client.graphql("DmMutedTimeline", {
76
- variables: {
77
- count: opts.count || 20,
78
- cursor: opts.cursor,
79
- ...opts.variables,
80
- },
81
- });
82
- },
83
-
84
- async edit(messageId, conversationId, text) {
85
- const res = await client.v1_1("dm/edit", {
86
- body: JSON.stringify({
87
- message_id: messageId,
88
- conversation_id: conversationId,
89
- text,
90
- }),
91
- });
92
- return await res.json();
93
- },
94
-
95
- async permissions(params = {}) {
96
- const res = await client.v1_1("dm/permissions", { params });
97
- return await res.json();
98
- },
99
-
100
- async nsfwFilter(enabled) {
101
- return await client.graphql("DmNsfwMediaFilterUpdate", {
102
- body: { variables: { enabled } },
103
- });
104
- },
105
-
106
- async updateRelationship(userId, action) {
107
- const res = await client.v1_1("dm/user/update_relationship_state", {
108
- body: JSON.stringify({ user_id: userId, action }),
109
- });
110
- return await res.json();
111
- },
112
-
113
- async reportSpam(conversationId, messageId) {
114
- const res = await client.v1_1("direct_messages/report_spam", {
115
- body: JSON.stringify({ conversation_id: conversationId, message_id: messageId }),
116
- });
117
- return await res.json();
118
- },
119
-
120
- async report(conversationId, messageId) {
121
- const res = await client.v1_1("dm/report", {
122
- body: JSON.stringify({ conversation_id: conversationId, message_id: messageId }),
123
- });
124
- return await res.json();
125
- },
126
-
127
- async userUpdates(params = {}) {
128
- const res = await client.v1_1("dm/user_updates", { params });
129
- return await res.json();
130
- },
131
- });
1
+ export async function inbox(params = {}) {
2
+ const res = await this.v1_1("dm/inbox_initial_state", { params });
3
+ return await res.json();
4
+ }
5
+
6
+ export async function conversation(conversationId, params = {}) {
7
+ const res = await this.v1_1("dm/conversation", {
8
+ params: { id: conversationId, ...params },
9
+ });
10
+ return await res.json();
11
+ }
12
+
13
+ export async function search(query, opts = {}) {
14
+ return await this.graphql("DmAllSearchSlice", {
15
+ variables: {
16
+ query,
17
+ count: opts.count || 20,
18
+ cursor: opts.cursor,
19
+ ...opts.variables,
20
+ },
21
+ });
22
+ }
23
+
24
+ export async function searchGroups(query, opts = {}) {
25
+ return await this.graphql("DmGroupSearchSlice", {
26
+ variables: {
27
+ query,
28
+ count: opts.count || 20,
29
+ cursor: opts.cursor,
30
+ ...opts.variables,
31
+ },
32
+ });
33
+ }
34
+
35
+ export async function searchPeople(query, opts = {}) {
36
+ return await this.graphql("DmPeopleSearchSlice", {
37
+ variables: {
38
+ query,
39
+ count: opts.count || 20,
40
+ cursor: opts.cursor,
41
+ ...opts.variables,
42
+ },
43
+ });
44
+ }
45
+
46
+ export async function block(userId) {
47
+ return await this.graphql("dmBlockUser", {
48
+ body: { variables: { user_id: userId } },
49
+ });
50
+ }
51
+
52
+ export async function unblock(userId) {
53
+ return await this.graphql("dmUnblockUser", {
54
+ body: { variables: { user_id: userId } },
55
+ });
56
+ }
57
+
58
+ export async function deleteConversations(conversationIds) {
59
+ const ids = Array.isArray(conversationIds) ? conversationIds : [conversationIds];
60
+ const res = await this.v1_1("dm/conversation/bulk_delete", {
61
+ body: JSON.stringify({ conversation_ids: ids }),
62
+ });
63
+ return await res.json();
64
+ }
65
+
66
+ export async function updateLastSeen(eventId) {
67
+ const res = await this.v1_1("dm/update_last_seen_event_id", {
68
+ body: JSON.stringify({ last_seen_event_id: eventId, trusted_last_seen_event_id: eventId }),
69
+ });
70
+ return await res.json();
71
+ }
72
+
73
+ export async function muted(opts = {}) {
74
+ return await this.graphql("DmMutedTimeline", {
75
+ variables: {
76
+ count: opts.count || 20,
77
+ cursor: opts.cursor,
78
+ ...opts.variables,
79
+ },
80
+ });
81
+ }
82
+
83
+ export async function edit(messageId, conversationId, text) {
84
+ const res = await this.v1_1("dm/edit", {
85
+ body: JSON.stringify({
86
+ message_id: messageId,
87
+ conversation_id: conversationId,
88
+ text,
89
+ }),
90
+ });
91
+ return await res.json();
92
+ }
93
+
94
+ export async function permissions(params = {}) {
95
+ const res = await this.v1_1("dm/permissions", { params });
96
+ return await res.json();
97
+ }
98
+
99
+ export async function nsfwFilter(enabled) {
100
+ return await this.graphql("DmNsfwMediaFilterUpdate", {
101
+ body: { variables: { enabled } },
102
+ });
103
+ }
104
+
105
+ export async function updateRelationship(userId, action) {
106
+ const res = await this.v1_1("dm/user/update_relationship_state", {
107
+ body: JSON.stringify({ user_id: userId, action }),
108
+ });
109
+ return await res.json();
110
+ }
111
+
112
+ export async function reportSpam(conversationId, messageId) {
113
+ const res = await this.v1_1("direct_messages/report_spam", {
114
+ body: JSON.stringify({ conversation_id: conversationId, message_id: messageId }),
115
+ });
116
+ return await res.json();
117
+ }
118
+
119
+ export async function report(conversationId, messageId) {
120
+ const res = await this.v1_1("dm/report", {
121
+ body: JSON.stringify({ conversation_id: conversationId, message_id: messageId }),
122
+ });
123
+ return await res.json();
124
+ }
125
+
126
+ export async function userUpdates(params = {}) {
127
+ const res = await this.v1_1("dm/user_updates", { params });
128
+ return await res.json();
129
+ }
@@ -1,32 +1,51 @@
1
- import account from "./account.js";
2
- import bookmarks from "./bookmarks.js";
3
- import communities from "./communities.js";
4
- import dms from "./dms.js";
5
- import lists from "./lists.js";
6
- import media from "./media.js";
7
- import notifications from "./notifications.js";
8
- import search from "./search.js";
9
- import spaces from "./spaces.js";
10
- import timelines from "./timelines.js";
11
- import topics from "./topics.js";
12
- import trends from "./trends.js";
13
- import tweets from "./tweets.js";
14
- import users from "./users.js";
1
+ import * as account from "./account.js";
2
+ import * as bookmarks from "./bookmarks.js";
3
+ import * as communities from "./communities.js";
4
+ import * as dms from "./dms.js";
5
+ import * as lists from "./lists.js";
6
+ import * as media from "./media.js";
7
+ import * as notifications from "./notifications.js";
8
+ import * as search from "./search.js";
9
+ import * as spaces from "./spaces.js";
10
+ import * as syndication from "./syndication.js";
11
+ import * as timelines from "./timelines.js";
12
+ import * as topics from "./topics.js";
13
+ import * as trends from "./trends.js";
14
+ import * as tweets from "./tweets.js";
15
+ import * as users from "./users.js";
15
16
 
16
- export default (client) => ({
17
- tweets: tweets(client),
18
- users: users(client),
19
- timelines: timelines(client),
20
- bookmarks: bookmarks(client),
21
- dms: dms(client),
22
- lists: lists(client),
23
- communities: communities(client),
24
- search: search(client),
25
- spaces: spaces(client),
26
- account: account(client),
27
- notifications: notifications(client),
28
- trends: trends(client),
29
- topics: topics(client),
30
- media: media(client),
31
- syndication: syndication(client),
32
- });
17
+ function namespace(proto, name, methods) {
18
+ Object.defineProperty(proto, name, {
19
+ get() {
20
+ const bound = {};
21
+ for (const [k, fn] of Object.entries(methods)) {
22
+ if (typeof fn === "function") bound[k] = fn.bind(this);
23
+ }
24
+ Object.defineProperty(this, name, {
25
+ value: bound,
26
+ writable: true,
27
+ configurable: true,
28
+ });
29
+ return bound;
30
+ },
31
+ configurable: true,
32
+ });
33
+ }
34
+
35
+ export default function initHelpers(proto) {
36
+ namespace(proto, "tweets", tweets);
37
+ namespace(proto, "users", users);
38
+ namespace(proto, "timelines", timelines);
39
+ namespace(proto, "bookmarks", bookmarks);
40
+ namespace(proto, "dms", dms);
41
+ namespace(proto, "lists", lists);
42
+ namespace(proto, "communities", communities);
43
+ namespace(proto, "search", search);
44
+ namespace(proto, "spaces", spaces);
45
+ namespace(proto, "account", account);
46
+ namespace(proto, "notifications", notifications);
47
+ namespace(proto, "trends", trends);
48
+ namespace(proto, "topics", topics);
49
+ namespace(proto, "media", media);
50
+ namespace(proto, "syndication", syndication);
51
+ }