@metamask/social-controllers 3.4.0 → 3.6.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.
- package/CHANGELOG.md +28 -1
- package/dist/SocialRealtimeService.d.ts +34 -0
- package/dist/SocialRealtimeService.d.ts.map +1 -0
- package/dist/SocialRealtimeService.js +126 -0
- package/dist/SocialRealtimeService.js.map +1 -0
- package/dist/SocialService-method-action-types.d.ts +49 -1
- package/dist/SocialService-method-action-types.d.ts.map +1 -1
- package/dist/SocialService-method-action-types.js.map +1 -1
- package/dist/SocialService.d.ts +40 -1
- package/dist/SocialService.d.ts.map +1 -1
- package/dist/SocialService.js +124 -0
- package/dist/SocialService.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/social-constants.d.ts +5 -0
- package/dist/social-constants.d.ts.map +1 -1
- package/dist/social-constants.js +5 -0
- package/dist/social-constants.js.map +1 -1
- package/dist/social-types.d.ts +80 -0
- package/dist/social-types.d.ts.map +1 -1
- package/dist/social-types.js.map +1 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.6.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add `block`, `fetchBlockedProfiles`, and `fetchBlockedContent` methods to `SocialService` (and the matching `SocialService:block`, `SocialService:fetchBlockedProfiles`, and `SocialService:fetchBlockedContent` messenger actions) for the social-api moderation block endpoints ([#10656](https://github.com/MetaMask/core/pull/10656))
|
|
15
|
+
- `block` calls `PUT /moderation/block` with exactly one of `profileId`, `commentId`, or `replyId`, plus an optional `reason`. The endpoint returns 204.
|
|
16
|
+
- `fetchBlockedProfiles` calls `GET /moderation/blocks/profiles` and returns traders the caller has blocked, most recently blocked first. Pass `cursor` from the previous page; `cursor` is `null` on the last page.
|
|
17
|
+
- `fetchBlockedContent` calls `GET /moderation/blocks/content` and returns comments and replies the caller has blocked, most recently blocked first, with the same cursor pagination.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Bump `@metamask/core-backend` from `^12.0.0` to `^12.0.1` ([#10662](https://github.com/MetaMask/core/pull/10662))
|
|
22
|
+
- Bump `@metamask/profile-sync-controller` from `^33.0.0` to `^34.0.0` ([#10662](https://github.com/MetaMask/core/pull/10662))
|
|
23
|
+
|
|
24
|
+
## [3.5.0]
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- Add `SocialRealtimeService` for subscribing to Social realtime feed events through the shared backend WebSocket connection ([#10561](https://github.com/MetaMask/core/pull/10561))
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- Bump `@metamask/base-data-service` from `^2.0.0` to `^2.1.0` ([#10502](https://github.com/MetaMask/core/pull/10502))
|
|
33
|
+
- Bump `@metamask/core-backend` from `^11.0.0` to `^12.0.0` ([#10648](https://github.com/MetaMask/core/pull/10648))
|
|
34
|
+
|
|
10
35
|
## [3.4.0]
|
|
11
36
|
|
|
12
37
|
### Added
|
|
@@ -225,7 +250,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
225
250
|
- `unfollowTrader` — unfollows traders and removes addresses from state
|
|
226
251
|
- `updateFollowing` — fetches following list and replaces addresses in state
|
|
227
252
|
|
|
228
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/social-controllers@3.
|
|
253
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/social-controllers@3.6.0...HEAD
|
|
254
|
+
[3.6.0]: https://github.com/MetaMask/core/compare/@metamask/social-controllers@3.5.0...@metamask/social-controllers@3.6.0
|
|
255
|
+
[3.5.0]: https://github.com/MetaMask/core/compare/@metamask/social-controllers@3.4.0...@metamask/social-controllers@3.5.0
|
|
229
256
|
[3.4.0]: https://github.com/MetaMask/core/compare/@metamask/social-controllers@3.3.0...@metamask/social-controllers@3.4.0
|
|
230
257
|
[3.3.0]: https://github.com/MetaMask/core/compare/@metamask/social-controllers@3.2.0...@metamask/social-controllers@3.3.0
|
|
231
258
|
[3.2.0]: https://github.com/MetaMask/core/compare/@metamask/social-controllers@3.1.0...@metamask/social-controllers@3.2.0
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BackendWebSocketServiceMessenger } from '@metamask/core-backend';
|
|
2
|
+
import type { FeedItem } from './social-types.js';
|
|
3
|
+
export declare const SOCIAL_FEED_CHANNEL: 'social.v1.feed.all';
|
|
4
|
+
export declare const SOCIAL_FEED_CHANNEL_TYPE: 'social.v1';
|
|
5
|
+
export type SocialFeedEvent = {
|
|
6
|
+
version: 1;
|
|
7
|
+
kind: 'feed-item';
|
|
8
|
+
eventId: string;
|
|
9
|
+
feedItemId: string;
|
|
10
|
+
revision: number;
|
|
11
|
+
occurredAt: string;
|
|
12
|
+
data: FeedItem;
|
|
13
|
+
};
|
|
14
|
+
export type SocialFeedEventListener = (event: SocialFeedEvent) => void;
|
|
15
|
+
export type SocialFeedReconnectListener = () => void;
|
|
16
|
+
export type SocialRealtimeServiceOptions = {
|
|
17
|
+
messenger: BackendWebSocketServiceMessenger;
|
|
18
|
+
isEnabled?: () => boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Social realtime subscription service built on the shared backend WebSocket.
|
|
22
|
+
*
|
|
23
|
+
* The POC subscribes to the global feed channel. Additional Social channels
|
|
24
|
+
* can be added here without creating another WebSocket connection.
|
|
25
|
+
*/
|
|
26
|
+
export declare class SocialRealtimeService {
|
|
27
|
+
#private;
|
|
28
|
+
readonly name: 'SocialRealtimeService';
|
|
29
|
+
constructor({ messenger, isEnabled, }: SocialRealtimeServiceOptions);
|
|
30
|
+
addListener(listener: SocialFeedEventListener): () => void;
|
|
31
|
+
addReconnectListener(listener: SocialFeedReconnectListener): () => void;
|
|
32
|
+
setActive(active: boolean): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=SocialRealtimeService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialRealtimeService.d.ts","sourceRoot":"","sources":["../src/SocialRealtimeService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gCAAgC,EAGjC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,eAAO,MAAM,mBAAmB,EAAG,oBAA6B,CAAC;AACjE,eAAO,MAAM,wBAAwB,EAAG,WAAoB,CAAC;AAE7D,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,CAAC,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;AACvE,MAAM,MAAM,2BAA2B,GAAG,MAAM,IAAI,CAAC;AAErD,MAAM,MAAM,4BAA4B,GAAG;IACzC,SAAS,EAAE,gCAAgC,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC;CAC3B,CAAC;AAuBF;;;;;GAKG;AACH,qBAAa,qBAAqB;;IAChC,QAAQ,CAAC,IAAI,EAAG,uBAAuB,CAAU;IAkBjD,YAAY,EACV,SAAS,EACT,SAA+B,GAChC,EAAE,4BAA4B,EAyB9B;IAED,WAAW,CAAC,QAAQ,EAAE,uBAAuB,GAAG,MAAM,IAAI,CAGzD;IAED,oBAAoB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,MAAM,IAAI,CAGtE;IAEK,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAS9C;CAyEF"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { WebSocketState } from '@metamask/core-backend';
|
|
2
|
+
export const SOCIAL_FEED_CHANNEL = 'social.v1.feed.all';
|
|
3
|
+
export const SOCIAL_FEED_CHANNEL_TYPE = 'social.v1';
|
|
4
|
+
const isRecord = (value) => typeof value === 'object' && value !== null;
|
|
5
|
+
const parseSocialFeedEvent = (data) => {
|
|
6
|
+
if (data.version !== 1 ||
|
|
7
|
+
data.kind !== 'feed-item' ||
|
|
8
|
+
typeof data.eventId !== 'string' ||
|
|
9
|
+
typeof data.feedItemId !== 'string' ||
|
|
10
|
+
typeof data.revision !== 'number' ||
|
|
11
|
+
typeof data.occurredAt !== 'string' ||
|
|
12
|
+
!isRecord(data.data)) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
return data;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Social realtime subscription service built on the shared backend WebSocket.
|
|
19
|
+
*
|
|
20
|
+
* The POC subscribes to the global feed channel. Additional Social channels
|
|
21
|
+
* can be added here without creating another WebSocket connection.
|
|
22
|
+
*/
|
|
23
|
+
export class SocialRealtimeService {
|
|
24
|
+
name = 'SocialRealtimeService';
|
|
25
|
+
#messenger;
|
|
26
|
+
#listeners = new Set();
|
|
27
|
+
#reconnectListeners = new Set();
|
|
28
|
+
#isEnabled;
|
|
29
|
+
#active = false;
|
|
30
|
+
#subscription;
|
|
31
|
+
#subscriptionPromise;
|
|
32
|
+
#wasDisconnected = false;
|
|
33
|
+
constructor({ messenger, isEnabled = () => true, }) {
|
|
34
|
+
this.#messenger = messenger;
|
|
35
|
+
this.#isEnabled = isEnabled;
|
|
36
|
+
this.#messenger.subscribe('BackendWebSocketService:connectionStateChanged', ({ state }) => {
|
|
37
|
+
if (state === WebSocketState.DISCONNECTED) {
|
|
38
|
+
this.#subscription = undefined;
|
|
39
|
+
this.#wasDisconnected = true;
|
|
40
|
+
}
|
|
41
|
+
if (state === WebSocketState.CONNECTED && this.#active) {
|
|
42
|
+
const isReconnect = this.#wasDisconnected;
|
|
43
|
+
this.#wasDisconnected = false;
|
|
44
|
+
// Subscription setup handles its own errors and must not block reconnect handling.
|
|
45
|
+
// eslint-disable-next-line no-void
|
|
46
|
+
void this.#subscribeToFeed();
|
|
47
|
+
if (isReconnect) {
|
|
48
|
+
this.#reconnectListeners.forEach((listener) => listener());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
addListener(listener) {
|
|
54
|
+
this.#listeners.add(listener);
|
|
55
|
+
return () => this.#listeners.delete(listener);
|
|
56
|
+
}
|
|
57
|
+
addReconnectListener(listener) {
|
|
58
|
+
this.#reconnectListeners.add(listener);
|
|
59
|
+
return () => this.#reconnectListeners.delete(listener);
|
|
60
|
+
}
|
|
61
|
+
async setActive(active) {
|
|
62
|
+
this.#active = active && this.#isEnabled();
|
|
63
|
+
if (!this.#active) {
|
|
64
|
+
await this.#unsubscribeFromFeed();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
await this.#subscribeToFeed();
|
|
68
|
+
}
|
|
69
|
+
async #subscribeToFeed() {
|
|
70
|
+
if (!this.#active || this.#subscription) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
while (this.#subscriptionPromise) {
|
|
74
|
+
await this.#subscriptionPromise;
|
|
75
|
+
if (!this.#active || this.#subscription) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const subscriptionPromise = Promise.resolve().then(async () => {
|
|
80
|
+
try {
|
|
81
|
+
await this.#messenger.call('BackendWebSocketService:connect');
|
|
82
|
+
// Each service needs its own callback and subscription lifecycle.
|
|
83
|
+
const subscription = await this.#messenger.call('BackendWebSocketService:subscribe', {
|
|
84
|
+
channels: [SOCIAL_FEED_CHANNEL],
|
|
85
|
+
channelType: SOCIAL_FEED_CHANNEL_TYPE,
|
|
86
|
+
callback: (notification) => {
|
|
87
|
+
this.#handleNotification(notification);
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
if (!this.#active) {
|
|
91
|
+
await subscription.unsubscribe();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.#subscription = subscription;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
this.#subscription = undefined;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
this.#subscriptionPromise = subscriptionPromise;
|
|
101
|
+
try {
|
|
102
|
+
await subscriptionPromise;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
this.#subscriptionPromise = undefined;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async #unsubscribeFromFeed() {
|
|
109
|
+
const subscription = this.#subscription;
|
|
110
|
+
this.#subscription = undefined;
|
|
111
|
+
if (subscription) {
|
|
112
|
+
await subscription.unsubscribe();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
#handleNotification(notification) {
|
|
116
|
+
if (notification.channel !== SOCIAL_FEED_CHANNEL) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const event = parseSocialFeedEvent(notification.data);
|
|
120
|
+
if (!event) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this.#listeners.forEach((listener) => listener(event));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=SocialRealtimeService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialRealtimeService.js","sourceRoot":"","sources":["../src/SocialRealtimeService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AASxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAA6B,CAAC;AACjE,MAAM,CAAC,MAAM,wBAAwB,GAAG,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a,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QAE/B,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,YAAY,CAAC,WAAW,EAAE,CAAC;QACnC,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,YAAuC;QACzD,IAAI,YAAY,CAAC,OAAO,KAAK,mBAAmB,EAAE,CAAC;YACjD,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG,oBAAoB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO;QACT,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["import { WebSocketState } from '@metamask/core-backend';\nimport type {\n BackendWebSocketServiceMessenger,\n ServerNotificationMessage,\n WebSocketSubscription,\n} from '@metamask/core-backend';\n\nimport type { FeedItem } from './social-types.js';\n\nexport const SOCIAL_FEED_CHANNEL = 'social.v1.feed.all' as const;\nexport const SOCIAL_FEED_CHANNEL_TYPE = 'social.v1' as const;\n\nexport type SocialFeedEvent = {\n version: 1;\n kind: 'feed-item';\n eventId: string;\n feedItemId: string;\n revision: number;\n occurredAt: string;\n data: FeedItem;\n};\n\nexport type SocialFeedEventListener = (event: SocialFeedEvent) => void;\nexport type SocialFeedReconnectListener = () => void;\n\nexport type SocialRealtimeServiceOptions = {\n messenger: BackendWebSocketServiceMessenger;\n isEnabled?: () => boolean;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null;\n\nconst parseSocialFeedEvent = (\n data: Record<string, unknown>,\n): SocialFeedEvent | undefined => {\n if (\n data.version !== 1 ||\n data.kind !== 'feed-item' ||\n typeof data.eventId !== 'string' ||\n typeof data.feedItemId !== 'string' ||\n typeof data.revision !== 'number' ||\n typeof data.occurredAt !== 'string' ||\n !isRecord(data.data)\n ) {\n return undefined;\n }\n\n return data as unknown as SocialFeedEvent;\n};\n\n/**\n * Social realtime subscription service built on the shared backend WebSocket.\n *\n * The POC subscribes to the global feed channel. Additional Social channels\n * can be added here without creating another WebSocket connection.\n */\nexport class SocialRealtimeService {\n readonly name = 'SocialRealtimeService' as const;\n\n readonly #messenger: BackendWebSocketServiceMessenger;\n\n readonly #listeners = new Set<SocialFeedEventListener>();\n\n readonly #reconnectListeners = new Set<SocialFeedReconnectListener>();\n\n readonly #isEnabled: () => boolean;\n\n #active = false;\n\n #subscription: WebSocketSubscription | undefined;\n\n #subscriptionPromise: Promise<void> | undefined;\n\n #wasDisconnected = false;\n\n constructor({\n messenger,\n isEnabled = (): boolean => true,\n }: SocialRealtimeServiceOptions) {\n this.#messenger = messenger;\n this.#isEnabled = isEnabled;\n\n this.#messenger.subscribe(\n 'BackendWebSocketService:connectionStateChanged',\n ({ state }: { state: WebSocketState }): void => {\n if (state === WebSocketState.DISCONNECTED) {\n this.#subscription = undefined;\n this.#wasDisconnected = true;\n }\n\n if (state === WebSocketState.CONNECTED && this.#active) {\n const isReconnect = this.#wasDisconnected;\n this.#wasDisconnected = false;\n // Subscription setup handles its own errors and must not block reconnect handling.\n // eslint-disable-next-line no-void\n void this.#subscribeToFeed();\n\n if (isReconnect) {\n this.#reconnectListeners.forEach((listener) => listener());\n }\n }\n },\n );\n }\n\n addListener(listener: SocialFeedEventListener): () => void {\n this.#listeners.add(listener);\n return () => this.#listeners.delete(listener);\n }\n\n addReconnectListener(listener: SocialFeedReconnectListener): () => void {\n this.#reconnectListeners.add(listener);\n return () => this.#reconnectListeners.delete(listener);\n }\n\n async setActive(active: boolean): Promise<void> {\n this.#active = active && this.#isEnabled();\n\n if (!this.#active) {\n await this.#unsubscribeFromFeed();\n return;\n }\n\n await this.#subscribeToFeed();\n }\n\n async #subscribeToFeed(): Promise<void> {\n if (!this.#active || this.#subscription) {\n return;\n }\n\n while (this.#subscriptionPromise) {\n await this.#subscriptionPromise;\n\n if (!this.#active || this.#subscription) {\n return;\n }\n }\n\n const subscriptionPromise = Promise.resolve().then(\n async (): Promise<void> => {\n try {\n await this.#messenger.call('BackendWebSocketService:connect');\n\n // Each service needs its own callback and subscription lifecycle.\n const subscription = await this.#messenger.call(\n 'BackendWebSocketService:subscribe',\n {\n channels: [SOCIAL_FEED_CHANNEL],\n channelType: SOCIAL_FEED_CHANNEL_TYPE,\n callback: (notification: ServerNotificationMessage) => {\n this.#handleNotification(notification);\n },\n },\n );\n\n if (!this.#active) {\n await subscription.unsubscribe();\n return;\n }\n\n this.#subscription = subscription;\n } catch {\n this.#subscription = undefined;\n }\n },\n );\n this.#subscriptionPromise = subscriptionPromise;\n\n try {\n await subscriptionPromise;\n } finally {\n this.#subscriptionPromise = undefined;\n }\n }\n\n async #unsubscribeFromFeed(): Promise<void> {\n const subscription = this.#subscription;\n this.#subscription = undefined;\n\n if (subscription) {\n await subscription.unsubscribe();\n }\n }\n\n #handleNotification(notification: ServerNotificationMessage): void {\n if (notification.channel !== SOCIAL_FEED_CHANNEL) {\n return;\n }\n\n const event = parseSocialFeedEvent(notification.data);\n if (!event) {\n return;\n }\n\n this.#listeners.forEach((listener) => listener(event));\n }\n}\n"]}
|
|
@@ -293,8 +293,56 @@ export type SocialServiceRefreshNotificationPreferencesCacheAction = {
|
|
|
293
293
|
type: `SocialService:refreshNotificationPreferencesCache`;
|
|
294
294
|
handler: SocialService['refreshNotificationPreferencesCache'];
|
|
295
295
|
};
|
|
296
|
+
/**
|
|
297
|
+
* Blocks a trader, swap comment, or reply for the current user.
|
|
298
|
+
*
|
|
299
|
+
* Calls `PUT ${baseUrl}/moderation/block`. Provide exactly one of
|
|
300
|
+
* `profileId`, `commentId`, or `replyId`. Blocking the same target again
|
|
301
|
+
* replaces `reason` when one is given. The caller is identified server-side
|
|
302
|
+
* from the JWT sub claim carried in the Authorization header.
|
|
303
|
+
*
|
|
304
|
+
* @param options - Options bag. Exactly one target, plus an optional reason.
|
|
305
|
+
* @param options.profileId - Profile id (UUID) of the trader to block.
|
|
306
|
+
* @param options.commentId - Swap comment to block.
|
|
307
|
+
* @param options.replyId - Comment reply to block.
|
|
308
|
+
* @param options.reason - Free-form reason stored on the block.
|
|
309
|
+
*/
|
|
310
|
+
export type SocialServiceBlockAction = {
|
|
311
|
+
type: `SocialService:block`;
|
|
312
|
+
handler: SocialService['block'];
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* Fetches traders the current user has blocked.
|
|
316
|
+
*
|
|
317
|
+
* Calls `GET ${baseUrl}/moderation/blocks/profiles`. Results are most
|
|
318
|
+
* recently blocked first, 250 per page. The caller is identified
|
|
319
|
+
* server-side from the JWT sub claim carried in the Authorization header.
|
|
320
|
+
*
|
|
321
|
+
* @param options - Options bag.
|
|
322
|
+
* @param options.cursor - Cursor from the previous page. Omit for the first page.
|
|
323
|
+
* @returns The blocked profiles page.
|
|
324
|
+
*/
|
|
325
|
+
export type SocialServiceFetchBlockedProfilesAction = {
|
|
326
|
+
type: `SocialService:fetchBlockedProfiles`;
|
|
327
|
+
handler: SocialService['fetchBlockedProfiles'];
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Fetches comments and replies the current user has blocked.
|
|
331
|
+
*
|
|
332
|
+
* Calls `GET ${baseUrl}/moderation/blocks/content`. Results are most
|
|
333
|
+
* recently blocked first, 250 per page. The caller is identified
|
|
334
|
+
* server-side from the JWT sub claim carried in the Authorization header.
|
|
335
|
+
*
|
|
336
|
+
* @param options - Options bag.
|
|
337
|
+
* @param options.cursor - Cursor from the previous page. Omit for the first page.
|
|
338
|
+
* @returns The blocked content page.
|
|
339
|
+
*/
|
|
340
|
+
export type SocialServiceFetchBlockedContentAction = {
|
|
341
|
+
type: `SocialService:fetchBlockedContent`;
|
|
342
|
+
handler: SocialService['fetchBlockedContent'];
|
|
343
|
+
};
|
|
296
344
|
/**
|
|
297
345
|
* Union of all SocialService action types.
|
|
298
346
|
*/
|
|
299
|
-
export type SocialServiceMethodActions = SocialServiceFetchLeaderboardAction | SocialServiceFetchTraderProfileAction | SocialServiceFetchOpenPositionsAction | SocialServiceFetchClosedPositionsAction | SocialServiceFetchFollowersAction | SocialServiceFetchPositionByIdAction | SocialServiceFetchFeedAction | SocialServiceFetchTraderFeedAction | SocialServiceFetchTokenFeedAction | SocialServiceReactToCommentAction | SocialServiceRemoveCommentReactionAction | SocialServiceCreateSwapCommentAction | SocialServiceFetchFollowingAction | SocialServiceFollowAction | SocialServiceUnfollowAction | SocialServiceOptOutOfLeaderboardAction | SocialServiceOptInToLeaderboardAction | SocialServiceRefreshNotificationPreferencesCacheAction;
|
|
347
|
+
export type SocialServiceMethodActions = SocialServiceFetchLeaderboardAction | SocialServiceFetchTraderProfileAction | SocialServiceFetchOpenPositionsAction | SocialServiceFetchClosedPositionsAction | SocialServiceFetchFollowersAction | SocialServiceFetchPositionByIdAction | SocialServiceFetchFeedAction | SocialServiceFetchTraderFeedAction | SocialServiceFetchTokenFeedAction | SocialServiceReactToCommentAction | SocialServiceRemoveCommentReactionAction | SocialServiceCreateSwapCommentAction | SocialServiceFetchFollowingAction | SocialServiceFollowAction | SocialServiceUnfollowAction | SocialServiceOptOutOfLeaderboardAction | SocialServiceOptInToLeaderboardAction | SocialServiceRefreshNotificationPreferencesCacheAction | SocialServiceBlockAction | SocialServiceFetchBlockedProfilesAction | SocialServiceFetchBlockedContentAction;
|
|
300
348
|
//# sourceMappingURL=SocialService-method-action-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SocialService-method-action-types.d.ts","sourceRoot":"","sources":["../src/SocialService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,aAAa,CAAC,kBAAkB,CAA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;;;;;;;;GAeG;AACH,MAAM,MAAM,sDAAsD,GAAG;IACnE,IAAI,EAAE,mDAAmD,CAAC;IAC1D,OAAO,EAAE,aAAa,CAAC,qCAAqC,CAAC,CAAC;CAC/D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,mCAAmC,GACnC,qCAAqC,GACrC,qCAAqC,GACrC,uCAAuC,GACvC,iCAAiC,GACjC,oCAAoC,GACpC,4BAA4B,GAC5B,kCAAkC,GAClC,iCAAiC,GACjC,iCAAiC,GACjC,wCAAwC,GACxC,oCAAoC,GACpC,iCAAiC,GACjC,yBAAyB,GACzB,2BAA2B,GAC3B,sCAAsC,GACtC,qCAAqC,GACrC,sDAAsD,CAAC"}
|
|
1
|
+
{"version":3,"file":"SocialService-method-action-types.d.ts","sourceRoot":"","sources":["../src/SocialService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;;;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AAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,mCAAmC,GACnC,qCAAqC,GACrC,qCAAqC,GACrC,uCAAuC,GACvC,iCAAiC,GACjC,oCAAoC,GACpC,4BAA4B,GAC5B,kCAAkC,GAClC,iCAAiC,GACjC,iCAAiC,GACjC,wCAAwC,GACxC,oCAAoC,GACpC,iCAAiC,GACjC,yBAAyB,GACzB,2BAA2B,GAC3B,sCAAsC,GACtC,qCAAqC,GACrC,sDAAsD,GACtD,wBAAwB,GACxB,uCAAuC,GACvC,sCAAsC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SocialService-method-action-types.js","sourceRoot":"","sources":["../src/SocialService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SocialService } from './SocialService.js';\n\n/**\n * Fetches the leaderboard of top traders.\n *\n * Calls `GET ${baseUrl}/leaderboard`.\n *\n * @param options - Optional query parameters for sorting, chain filtering, and limit.\n * @returns The leaderboard response with ranked traders.\n */\nexport type SocialServiceFetchLeaderboardAction = {\n type: `SocialService:fetchLeaderboard`;\n handler: SocialService['fetchLeaderboard'];\n};\n\n/**\n * Fetches a trader's profile by address or profile ID.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/profile`.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @returns The trader profile response.\n */\nexport type SocialServiceFetchTraderProfileAction = {\n type: `SocialService:fetchTraderProfile`;\n handler: SocialService['fetchTraderProfile'];\n};\n\n/**\n * Fetches a trader's open positions.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/positions/open`.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @param options.chain - Filter by chain.\n * @param options.sort - Sort by 'value' or 'latest'.\n * @param options.limit - Number of results per page.\n * @param options.page - Page number (1-based).\n * @returns The positions response.\n */\nexport type SocialServiceFetchOpenPositionsAction = {\n type: `SocialService:fetchOpenPositions`;\n handler: SocialService['fetchOpenPositions'];\n};\n\n/**\n * Fetches a trader's closed positions.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/positions/closed`.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @param options.chain - Filter by chain.\n * @param options.sort - Sort by 'value' or 'latest'.\n * @param options.limit - Number of results per page.\n * @param options.page - Page number (1-based).\n * @returns The positions response.\n */\nexport type SocialServiceFetchClosedPositionsAction = {\n type: `SocialService:fetchClosedPositions`;\n handler: SocialService['fetchClosedPositions'];\n};\n\n/**\n * Fetches a trader's MetaMask followers.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/followers`.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @returns The followers response.\n */\nexport type SocialServiceFetchFollowersAction = {\n type: `SocialService:fetchFollowers`;\n handler: SocialService['fetchFollowers'];\n};\n\n/**\n * Fetches a single position by its unique ID.\n *\n * Calls `GET ${baseUrl}/traders/position/${positionId}`.\n *\n * @param options - Options bag.\n * @param options.positionId - Unique position ID (UUID).\n * @returns The position.\n */\nexport type SocialServiceFetchPositionByIdAction = {\n type: `SocialService:fetchPositionById`;\n handler: SocialService['fetchPositionById'];\n};\n\n/**\n * Fetches a page of the trader-activity feed.\n *\n * Calls `GET ${baseUrl}/feed`. For the `following` scope the current user is\n * identified server-side from the JWT sub claim carried in the Authorization\n * header; the `leaderboard` scope is generic and shared by all users.\n *\n * Cursor pagination supports infinite scroll: pass `pagination.olderCursor`\n * from a prior response back as `olderThan` to load older items, and\n * `pagination.newerCursor` as `newerThan` to fetch newer items.\n *\n * @param options - Options bag.\n * @param options.scope - `following` (default) or `leaderboard`.\n * @param options.chains - Filter by one or more chains.\n * @param options.limit - Number of results per page.\n * @param options.olderThan - Cursor for older items (scroll down).\n * @param options.newerThan - Cursor for newer items (refresh).\n * @returns The feed response with items and pagination cursors.\n */\nexport type SocialServiceFetchFeedAction = {\n type: `SocialService:fetchFeed`;\n handler: SocialService['fetchFeed'];\n};\n\n/**\n * Fetches a page of one trader's activity as feed items.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/feed`. Unlike {@link fetchFeed},\n * this is scoped to a single profile (open and closed positions in the feed)\n * and does not accept `scope` or `chains`. Set `commentedOnly` to only return\n * positions that carry an author comment.\n *\n * The route is public, but the Authorization header is still sent so the\n * social-api can hydrate `authorComment.engagement.userReaction` for the\n * signed-in viewer.\n *\n * Cursor pagination supports infinite scroll: pass `pagination.olderCursor`\n * from a prior response back as `olderThan` to load older items, and\n * `pagination.newerCursor` as `newerThan` to fetch newer items.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @param options.commentedOnly - When true, only positions with a comment.\n * @param options.limit - Number of results per page.\n * @param options.olderThan - Cursor for older items (scroll down).\n * @param options.newerThan - Cursor for newer items (refresh).\n * @returns The feed response with items and pagination cursors.\n */\nexport type SocialServiceFetchTraderFeedAction = {\n type: `SocialService:fetchTraderFeed`;\n handler: SocialService['fetchTraderFeed'];\n};\n\n/**\n * Fetches a page of positions in one token, most recently traded first.\n *\n * Calls `GET ${baseUrl}/tokens/${chain}/${contractAddress}/feed`. Unlike\n * {@link fetchFeed}, this is scoped to a single token and does not accept\n * `scope` or `chains`. Omit `status` to include both open and recently\n * closed positions.\n *\n * The route is public, but the Authorization header is still sent so the\n * social-api can hydrate `authorComment.engagement.userReaction` for the\n * signed-in viewer.\n *\n * Cursor pagination supports infinite scroll: pass `pagination.olderCursor`\n * from a prior response back as `olderThan` to load older items, and\n * `pagination.newerCursor` as `newerThan` to fetch newer items.\n *\n * @param options - Options bag.\n * @param options.chain - Chain name where the token is deployed (`TokenFeedChain`).\n * @param options.contractAddress - Token contract address.\n * @param options.status - `open`, `closed`, or omit for both.\n * @param options.limit - Number of results per page.\n * @param options.olderThan - Cursor for older items (scroll down).\n * @param options.newerThan - Cursor for newer items (refresh).\n * @returns The feed response with items and pagination cursors.\n */\nexport type SocialServiceFetchTokenFeedAction = {\n type: `SocialService:fetchTokenFeed`;\n handler: SocialService['fetchTokenFeed'];\n};\n\n/**\n * Adds or replaces the current user's reaction on a swap comment (Call).\n *\n * Calls `PUT ${baseUrl}/swap-comment/${commentId}/reaction`. One emotion per\n * user per comment: a later PUT replaces the previous emotion.\n *\n * @param options - Options bag.\n * @param options.commentId - `authorComment.uid` from a feed item.\n * @param options.emotion - Emoji or short code to store.\n * @returns Refreshed per-emotion counts and the caller's `userReaction`.\n */\nexport type SocialServiceReactToCommentAction = {\n type: `SocialService:reactToComment`;\n handler: SocialService['reactToComment'];\n};\n\n/**\n * Removes the current user's reaction on a swap comment (Call).\n *\n * Calls `DELETE ${baseUrl}/swap-comment/${commentId}/reaction`. Idempotent\n * when the caller has never reacted.\n *\n * @param options - Options bag.\n * @param options.commentId - `authorComment.uid` from a feed item.\n * @returns Refreshed per-emotion counts and a null `userReaction`.\n */\nexport type SocialServiceRemoveCommentReactionAction = {\n type: `SocialService:removeCommentReaction`;\n handler: SocialService['removeCommentReaction'];\n};\n\n/**\n * Creates an author Call (user post) on one of the current user's swaps.\n *\n * Calls `POST ${baseUrl}/swap-comments`. Identify the swap with\n * `positionUid` (the `positionId` of a feed item or position) or, for a\n * trade too recent to be indexed, `tradeInFlight`. Provide exactly one of\n * those two fields.\n *\n * @param options - Options bag.\n * @param options.commentText - Message body of the post. May include a\n * `https://static.klipy.com/...gif` file URL; social-api rejects other links.\n * @param options.source - Free-form origin label stored on the comment.\n * @param options.positionUid - Position UUID (`positionId` / feed item id).\n * @param options.tradeInFlight - Hash, chain, and token of a swap in flight.\n * @returns The created swap comment.\n */\nexport type SocialServiceCreateSwapCommentAction = {\n type: `SocialService:createSwapComment`;\n handler: SocialService['createSwapComment'];\n};\n\n/**\n * Fetches the list of traders the current user is following.\n *\n * Calls `GET ${baseUrl}/users/me/following`. The caller is identified\n * server-side from the JWT sub claim carried in the Authorization header.\n *\n * @returns The following response.\n */\nexport type SocialServiceFetchFollowingAction = {\n type: `SocialService:fetchFollowing`;\n handler: SocialService['fetchFollowing'];\n};\n\n/**\n * Follows one or more traders on behalf of the current user.\n *\n * Calls `PUT ${baseUrl}/users/me/follows`. The caller is identified\n * server-side from the JWT sub claim carried in the Authorization header.\n *\n * @param options - Options bag.\n * @param options.targets - Array of wallet addresses or profile IDs to follow.\n * @returns The follow response with confirmed follows.\n */\nexport type SocialServiceFollowAction = {\n type: `SocialService:follow`;\n handler: SocialService['follow'];\n};\n\n/**\n * Unfollows one or more traders on behalf of the current user.\n *\n * Calls `DELETE ${baseUrl}/users/me/follows?targets=...`. Targets are sent\n * as query params because Fastify does not parse request bodies on DELETE\n * requests per RFC 9110. The caller is identified server-side from the JWT\n * sub claim carried in the Authorization header.\n *\n * @param options - Options bag.\n * @param options.targets - Array of wallet addresses or profile IDs to unfollow.\n * @returns The unfollow response with confirmed unfollows.\n */\nexport type SocialServiceUnfollowAction = {\n type: `SocialService:unfollow`;\n handler: SocialService['unfollow'];\n};\n\n/**\n * Opts the current user out of the PnL leaderboard.\n */\nexport type SocialServiceOptOutOfLeaderboardAction = {\n type: `SocialService:optOutOfLeaderboard`;\n handler: SocialService['optOutOfLeaderboard'];\n};\n\n/**\n * Opts the current user back into the PnL leaderboard.\n */\nexport type SocialServiceOptInToLeaderboardAction = {\n type: `SocialService:optInToLeaderboard`;\n handler: SocialService['optInToLeaderboard'];\n};\n\n/**\n * Asks the social-api to refresh its cached copy of the current user's\n * notification preferences.\n *\n * Calls `POST ${baseUrl}/notifications/preferences/cache-refresh`. The caller\n * is identified server-side from the JWT sub claim carried in the\n * Authorization header, so it can only ever refresh its own entry.\n *\n * The client calls this immediately after writing a preference change to\n * Authenticated User Storage (AUS), which is the source of truth. The social\n * api re-reads from AUS and repopulates its cache so the change is honoured\n * near-instantly rather than after the cache TTL lapses. It is a pure\n * optimisation on top of that bounded TTL: the write has already succeeded by\n * the time this runs, so callers should treat it as best-effort and must not\n * roll back the AUS write if it fails.\n */\nexport type SocialServiceRefreshNotificationPreferencesCacheAction = {\n type: `SocialService:refreshNotificationPreferencesCache`;\n handler: SocialService['refreshNotificationPreferencesCache'];\n};\n\n/**\n * Union of all SocialService action types.\n */\nexport type SocialServiceMethodActions =\n | SocialServiceFetchLeaderboardAction\n | SocialServiceFetchTraderProfileAction\n | SocialServiceFetchOpenPositionsAction\n | SocialServiceFetchClosedPositionsAction\n | SocialServiceFetchFollowersAction\n | SocialServiceFetchPositionByIdAction\n | SocialServiceFetchFeedAction\n | SocialServiceFetchTraderFeedAction\n | SocialServiceFetchTokenFeedAction\n | SocialServiceReactToCommentAction\n | SocialServiceRemoveCommentReactionAction\n | SocialServiceCreateSwapCommentAction\n | SocialServiceFetchFollowingAction\n | SocialServiceFollowAction\n | SocialServiceUnfollowAction\n | SocialServiceOptOutOfLeaderboardAction\n | SocialServiceOptInToLeaderboardAction\n | SocialServiceRefreshNotificationPreferencesCacheAction;\n"]}
|
|
1
|
+
{"version":3,"file":"SocialService-method-action-types.js","sourceRoot":"","sources":["../src/SocialService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SocialService } from './SocialService.js';\n\n/**\n * Fetches the leaderboard of top traders.\n *\n * Calls `GET ${baseUrl}/leaderboard`.\n *\n * @param options - Optional query parameters for sorting, chain filtering, and limit.\n * @returns The leaderboard response with ranked traders.\n */\nexport type SocialServiceFetchLeaderboardAction = {\n type: `SocialService:fetchLeaderboard`;\n handler: SocialService['fetchLeaderboard'];\n};\n\n/**\n * Fetches a trader's profile by address or profile ID.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/profile`.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @returns The trader profile response.\n */\nexport type SocialServiceFetchTraderProfileAction = {\n type: `SocialService:fetchTraderProfile`;\n handler: SocialService['fetchTraderProfile'];\n};\n\n/**\n * Fetches a trader's open positions.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/positions/open`.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @param options.chain - Filter by chain.\n * @param options.sort - Sort by 'value' or 'latest'.\n * @param options.limit - Number of results per page.\n * @param options.page - Page number (1-based).\n * @returns The positions response.\n */\nexport type SocialServiceFetchOpenPositionsAction = {\n type: `SocialService:fetchOpenPositions`;\n handler: SocialService['fetchOpenPositions'];\n};\n\n/**\n * Fetches a trader's closed positions.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/positions/closed`.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @param options.chain - Filter by chain.\n * @param options.sort - Sort by 'value' or 'latest'.\n * @param options.limit - Number of results per page.\n * @param options.page - Page number (1-based).\n * @returns The positions response.\n */\nexport type SocialServiceFetchClosedPositionsAction = {\n type: `SocialService:fetchClosedPositions`;\n handler: SocialService['fetchClosedPositions'];\n};\n\n/**\n * Fetches a trader's MetaMask followers.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/followers`.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @returns The followers response.\n */\nexport type SocialServiceFetchFollowersAction = {\n type: `SocialService:fetchFollowers`;\n handler: SocialService['fetchFollowers'];\n};\n\n/**\n * Fetches a single position by its unique ID.\n *\n * Calls `GET ${baseUrl}/traders/position/${positionId}`.\n *\n * @param options - Options bag.\n * @param options.positionId - Unique position ID (UUID).\n * @returns The position.\n */\nexport type SocialServiceFetchPositionByIdAction = {\n type: `SocialService:fetchPositionById`;\n handler: SocialService['fetchPositionById'];\n};\n\n/**\n * Fetches a page of the trader-activity feed.\n *\n * Calls `GET ${baseUrl}/feed`. For the `following` scope the current user is\n * identified server-side from the JWT sub claim carried in the Authorization\n * header; the `leaderboard` scope is generic and shared by all users.\n *\n * Cursor pagination supports infinite scroll: pass `pagination.olderCursor`\n * from a prior response back as `olderThan` to load older items, and\n * `pagination.newerCursor` as `newerThan` to fetch newer items.\n *\n * @param options - Options bag.\n * @param options.scope - `following` (default) or `leaderboard`.\n * @param options.chains - Filter by one or more chains.\n * @param options.limit - Number of results per page.\n * @param options.olderThan - Cursor for older items (scroll down).\n * @param options.newerThan - Cursor for newer items (refresh).\n * @returns The feed response with items and pagination cursors.\n */\nexport type SocialServiceFetchFeedAction = {\n type: `SocialService:fetchFeed`;\n handler: SocialService['fetchFeed'];\n};\n\n/**\n * Fetches a page of one trader's activity as feed items.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/feed`. Unlike {@link fetchFeed},\n * this is scoped to a single profile (open and closed positions in the feed)\n * and does not accept `scope` or `chains`. Set `commentedOnly` to only return\n * positions that carry an author comment.\n *\n * The route is public, but the Authorization header is still sent so the\n * social-api can hydrate `authorComment.engagement.userReaction` for the\n * signed-in viewer.\n *\n * Cursor pagination supports infinite scroll: pass `pagination.olderCursor`\n * from a prior response back as `olderThan` to load older items, and\n * `pagination.newerCursor` as `newerThan` to fetch newer items.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @param options.commentedOnly - When true, only positions with a comment.\n * @param options.limit - Number of results per page.\n * @param options.olderThan - Cursor for older items (scroll down).\n * @param options.newerThan - Cursor for newer items (refresh).\n * @returns The feed response with items and pagination cursors.\n */\nexport type SocialServiceFetchTraderFeedAction = {\n type: `SocialService:fetchTraderFeed`;\n handler: SocialService['fetchTraderFeed'];\n};\n\n/**\n * Fetches a page of positions in one token, most recently traded first.\n *\n * Calls `GET ${baseUrl}/tokens/${chain}/${contractAddress}/feed`. Unlike\n * {@link fetchFeed}, this is scoped to a single token and does not accept\n * `scope` or `chains`. Omit `status` to include both open and recently\n * closed positions.\n *\n * The route is public, but the Authorization header is still sent so the\n * social-api can hydrate `authorComment.engagement.userReaction` for the\n * signed-in viewer.\n *\n * Cursor pagination supports infinite scroll: pass `pagination.olderCursor`\n * from a prior response back as `olderThan` to load older items, and\n * `pagination.newerCursor` as `newerThan` to fetch newer items.\n *\n * @param options - Options bag.\n * @param options.chain - Chain name where the token is deployed (`TokenFeedChain`).\n * @param options.contractAddress - Token contract address.\n * @param options.status - `open`, `closed`, or omit for both.\n * @param options.limit - Number of results per page.\n * @param options.olderThan - Cursor for older items (scroll down).\n * @param options.newerThan - Cursor for newer items (refresh).\n * @returns The feed response with items and pagination cursors.\n */\nexport type SocialServiceFetchTokenFeedAction = {\n type: `SocialService:fetchTokenFeed`;\n handler: SocialService['fetchTokenFeed'];\n};\n\n/**\n * Adds or replaces the current user's reaction on a swap comment (Call).\n *\n * Calls `PUT ${baseUrl}/swap-comment/${commentId}/reaction`. One emotion per\n * user per comment: a later PUT replaces the previous emotion.\n *\n * @param options - Options bag.\n * @param options.commentId - `authorComment.uid` from a feed item.\n * @param options.emotion - Emoji or short code to store.\n * @returns Refreshed per-emotion counts and the caller's `userReaction`.\n */\nexport type SocialServiceReactToCommentAction = {\n type: `SocialService:reactToComment`;\n handler: SocialService['reactToComment'];\n};\n\n/**\n * Removes the current user's reaction on a swap comment (Call).\n *\n * Calls `DELETE ${baseUrl}/swap-comment/${commentId}/reaction`. Idempotent\n * when the caller has never reacted.\n *\n * @param options - Options bag.\n * @param options.commentId - `authorComment.uid` from a feed item.\n * @returns Refreshed per-emotion counts and a null `userReaction`.\n */\nexport type SocialServiceRemoveCommentReactionAction = {\n type: `SocialService:removeCommentReaction`;\n handler: SocialService['removeCommentReaction'];\n};\n\n/**\n * Creates an author Call (user post) on one of the current user's swaps.\n *\n * Calls `POST ${baseUrl}/swap-comments`. Identify the swap with\n * `positionUid` (the `positionId` of a feed item or position) or, for a\n * trade too recent to be indexed, `tradeInFlight`. Provide exactly one of\n * those two fields.\n *\n * @param options - Options bag.\n * @param options.commentText - Message body of the post. May include a\n * `https://static.klipy.com/...gif` file URL; social-api rejects other links.\n * @param options.source - Free-form origin label stored on the comment.\n * @param options.positionUid - Position UUID (`positionId` / feed item id).\n * @param options.tradeInFlight - Hash, chain, and token of a swap in flight.\n * @returns The created swap comment.\n */\nexport type SocialServiceCreateSwapCommentAction = {\n type: `SocialService:createSwapComment`;\n handler: SocialService['createSwapComment'];\n};\n\n/**\n * Fetches the list of traders the current user is following.\n *\n * Calls `GET ${baseUrl}/users/me/following`. The caller is identified\n * server-side from the JWT sub claim carried in the Authorization header.\n *\n * @returns The following response.\n */\nexport type SocialServiceFetchFollowingAction = {\n type: `SocialService:fetchFollowing`;\n handler: SocialService['fetchFollowing'];\n};\n\n/**\n * Follows one or more traders on behalf of the current user.\n *\n * Calls `PUT ${baseUrl}/users/me/follows`. The caller is identified\n * server-side from the JWT sub claim carried in the Authorization header.\n *\n * @param options - Options bag.\n * @param options.targets - Array of wallet addresses or profile IDs to follow.\n * @returns The follow response with confirmed follows.\n */\nexport type SocialServiceFollowAction = {\n type: `SocialService:follow`;\n handler: SocialService['follow'];\n};\n\n/**\n * Unfollows one or more traders on behalf of the current user.\n *\n * Calls `DELETE ${baseUrl}/users/me/follows?targets=...`. Targets are sent\n * as query params because Fastify does not parse request bodies on DELETE\n * requests per RFC 9110. The caller is identified server-side from the JWT\n * sub claim carried in the Authorization header.\n *\n * @param options - Options bag.\n * @param options.targets - Array of wallet addresses or profile IDs to unfollow.\n * @returns The unfollow response with confirmed unfollows.\n */\nexport type SocialServiceUnfollowAction = {\n type: `SocialService:unfollow`;\n handler: SocialService['unfollow'];\n};\n\n/**\n * Opts the current user out of the PnL leaderboard.\n */\nexport type SocialServiceOptOutOfLeaderboardAction = {\n type: `SocialService:optOutOfLeaderboard`;\n handler: SocialService['optOutOfLeaderboard'];\n};\n\n/**\n * Opts the current user back into the PnL leaderboard.\n */\nexport type SocialServiceOptInToLeaderboardAction = {\n type: `SocialService:optInToLeaderboard`;\n handler: SocialService['optInToLeaderboard'];\n};\n\n/**\n * Asks the social-api to refresh its cached copy of the current user's\n * notification preferences.\n *\n * Calls `POST ${baseUrl}/notifications/preferences/cache-refresh`. The caller\n * is identified server-side from the JWT sub claim carried in the\n * Authorization header, so it can only ever refresh its own entry.\n *\n * The client calls this immediately after writing a preference change to\n * Authenticated User Storage (AUS), which is the source of truth. The social\n * api re-reads from AUS and repopulates its cache so the change is honoured\n * near-instantly rather than after the cache TTL lapses. It is a pure\n * optimisation on top of that bounded TTL: the write has already succeeded by\n * the time this runs, so callers should treat it as best-effort and must not\n * roll back the AUS write if it fails.\n */\nexport type SocialServiceRefreshNotificationPreferencesCacheAction = {\n type: `SocialService:refreshNotificationPreferencesCache`;\n handler: SocialService['refreshNotificationPreferencesCache'];\n};\n\n/**\n * Blocks a trader, swap comment, or reply for the current user.\n *\n * Calls `PUT ${baseUrl}/moderation/block`. Provide exactly one of\n * `profileId`, `commentId`, or `replyId`. Blocking the same target again\n * replaces `reason` when one is given. The caller is identified server-side\n * from the JWT sub claim carried in the Authorization header.\n *\n * @param options - Options bag. Exactly one target, plus an optional reason.\n * @param options.profileId - Profile id (UUID) of the trader to block.\n * @param options.commentId - Swap comment to block.\n * @param options.replyId - Comment reply to block.\n * @param options.reason - Free-form reason stored on the block.\n */\nexport type SocialServiceBlockAction = {\n type: `SocialService:block`;\n handler: SocialService['block'];\n};\n\n/**\n * Fetches traders the current user has blocked.\n *\n * Calls `GET ${baseUrl}/moderation/blocks/profiles`. Results are most\n * recently blocked first, 250 per page. The caller is identified\n * server-side from the JWT sub claim carried in the Authorization header.\n *\n * @param options - Options bag.\n * @param options.cursor - Cursor from the previous page. Omit for the first page.\n * @returns The blocked profiles page.\n */\nexport type SocialServiceFetchBlockedProfilesAction = {\n type: `SocialService:fetchBlockedProfiles`;\n handler: SocialService['fetchBlockedProfiles'];\n};\n\n/**\n * Fetches comments and replies the current user has blocked.\n *\n * Calls `GET ${baseUrl}/moderation/blocks/content`. Results are most\n * recently blocked first, 250 per page. The caller is identified\n * server-side from the JWT sub claim carried in the Authorization header.\n *\n * @param options - Options bag.\n * @param options.cursor - Cursor from the previous page. Omit for the first page.\n * @returns The blocked content page.\n */\nexport type SocialServiceFetchBlockedContentAction = {\n type: `SocialService:fetchBlockedContent`;\n handler: SocialService['fetchBlockedContent'];\n};\n\n/**\n * Union of all SocialService action types.\n */\nexport type SocialServiceMethodActions =\n | SocialServiceFetchLeaderboardAction\n | SocialServiceFetchTraderProfileAction\n | SocialServiceFetchOpenPositionsAction\n | SocialServiceFetchClosedPositionsAction\n | SocialServiceFetchFollowersAction\n | SocialServiceFetchPositionByIdAction\n | SocialServiceFetchFeedAction\n | SocialServiceFetchTraderFeedAction\n | SocialServiceFetchTokenFeedAction\n | SocialServiceReactToCommentAction\n | SocialServiceRemoveCommentReactionAction\n | SocialServiceCreateSwapCommentAction\n | SocialServiceFetchFollowingAction\n | SocialServiceFollowAction\n | SocialServiceUnfollowAction\n | SocialServiceOptOutOfLeaderboardAction\n | SocialServiceOptInToLeaderboardAction\n | SocialServiceRefreshNotificationPreferencesCacheAction\n | SocialServiceBlockAction\n | SocialServiceFetchBlockedProfilesAction\n | SocialServiceFetchBlockedContentAction;\n"]}
|
package/dist/SocialService.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { CreateServicePolicyOptions } from '@metamask/controller-utils';
|
|
|
4
4
|
import type { Messenger } from '@metamask/messenger';
|
|
5
5
|
import type { AuthenticationController } from '@metamask/profile-sync-controller';
|
|
6
6
|
import { serviceName } from './social-constants.js';
|
|
7
|
-
import type { CommentEngagement, CreateSwapCommentOptions, FeedResponse, FetchFeedOptions, FetchFollowersOptions, FetchLeaderboardOptions, FetchPositionByIdOptions, FetchPositionsOptions, FetchTokenFeedOptions, FetchTraderFeedOptions, FetchTraderProfileOptions, FollowersResponse, FollowingResponse, FollowOptions, FollowResponse, LeaderboardResponse, Position, PositionsResponse, ReactToCommentOptions, RemoveCommentReactionOptions, SwapCommentResponse, TraderProfileResponse, UnfollowOptions, UnfollowResponse } from './social-types.js';
|
|
7
|
+
import type { BlockedContentResponse, BlockedProfilesResponse, BlockOptions, CommentEngagement, CreateSwapCommentOptions, FeedResponse, FetchBlockedListOptions, FetchFeedOptions, FetchFollowersOptions, FetchLeaderboardOptions, FetchPositionByIdOptions, FetchPositionsOptions, FetchTokenFeedOptions, FetchTraderFeedOptions, FetchTraderProfileOptions, FollowersResponse, FollowingResponse, FollowOptions, FollowResponse, LeaderboardResponse, Position, PositionsResponse, ReactToCommentOptions, RemoveCommentReactionOptions, SwapCommentResponse, TraderProfileResponse, UnfollowOptions, UnfollowResponse } from './social-types.js';
|
|
8
8
|
import type { SocialServiceMethodActions } from './SocialService-method-action-types.js';
|
|
9
9
|
export type SocialServiceActions = SocialServiceMethodActions | DataServiceInvalidateQueriesAction<typeof serviceName>;
|
|
10
10
|
export type SocialServiceEvents = DataServiceCacheUpdatedEvent<typeof serviceName> | DataServiceGranularCacheUpdatedEvent<typeof serviceName>;
|
|
@@ -257,6 +257,45 @@ export declare class SocialService extends BaseDataService<typeof serviceName, S
|
|
|
257
257
|
* roll back the AUS write if it fails.
|
|
258
258
|
*/
|
|
259
259
|
refreshNotificationPreferencesCache(): Promise<void>;
|
|
260
|
+
/**
|
|
261
|
+
* Blocks a trader, swap comment, or reply for the current user.
|
|
262
|
+
*
|
|
263
|
+
* Calls `PUT ${baseUrl}/moderation/block`. Provide exactly one of
|
|
264
|
+
* `profileId`, `commentId`, or `replyId`. Blocking the same target again
|
|
265
|
+
* replaces `reason` when one is given. The caller is identified server-side
|
|
266
|
+
* from the JWT sub claim carried in the Authorization header.
|
|
267
|
+
*
|
|
268
|
+
* @param options - Options bag. Exactly one target, plus an optional reason.
|
|
269
|
+
* @param options.profileId - Profile id (UUID) of the trader to block.
|
|
270
|
+
* @param options.commentId - Swap comment to block.
|
|
271
|
+
* @param options.replyId - Comment reply to block.
|
|
272
|
+
* @param options.reason - Free-form reason stored on the block.
|
|
273
|
+
*/
|
|
274
|
+
block(options: BlockOptions): Promise<void>;
|
|
275
|
+
/**
|
|
276
|
+
* Fetches traders the current user has blocked.
|
|
277
|
+
*
|
|
278
|
+
* Calls `GET ${baseUrl}/moderation/blocks/profiles`. Results are most
|
|
279
|
+
* recently blocked first, 250 per page. The caller is identified
|
|
280
|
+
* server-side from the JWT sub claim carried in the Authorization header.
|
|
281
|
+
*
|
|
282
|
+
* @param options - Options bag.
|
|
283
|
+
* @param options.cursor - Cursor from the previous page. Omit for the first page.
|
|
284
|
+
* @returns The blocked profiles page.
|
|
285
|
+
*/
|
|
286
|
+
fetchBlockedProfiles(options?: FetchBlockedListOptions): Promise<BlockedProfilesResponse>;
|
|
287
|
+
/**
|
|
288
|
+
* Fetches comments and replies the current user has blocked.
|
|
289
|
+
*
|
|
290
|
+
* Calls `GET ${baseUrl}/moderation/blocks/content`. Results are most
|
|
291
|
+
* recently blocked first, 250 per page. The caller is identified
|
|
292
|
+
* server-side from the JWT sub claim carried in the Authorization header.
|
|
293
|
+
*
|
|
294
|
+
* @param options - Options bag.
|
|
295
|
+
* @param options.cursor - Cursor from the previous page. Omit for the first page.
|
|
296
|
+
* @returns The blocked content page.
|
|
297
|
+
*/
|
|
298
|
+
fetchBlockedContent(options?: FetchBlockedListOptions): Promise<BlockedContentResponse>;
|
|
260
299
|
}
|
|
261
300
|
export {};
|
|
262
301
|
//# sourceMappingURL=SocialService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SocialService.d.ts","sourceRoot":"","sources":["../src/SocialService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAelF,OAAO,EAAE,WAAW,EAA6B,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACxB,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,EACjB,qBAAqB,EACrB,4BAA4B,EAC5B,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"SocialService.d.ts","sourceRoot":"","sources":["../src/SocialService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EACnC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAelF,OAAO,EAAE,WAAW,EAA6B,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,EACjB,i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,IAAI,OAAO,CAAC,IAAI,CAAC,CAkBzC;IAED;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAkBxC;IAED;;;;;;;;;;;;;;;OAeG;IACG,mCAAmC,IAAI,OAAO,CAAC,IAAI,CAAC,CAkBzD;IAED;;;;;;;;;;;;;OAaG;IACG,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBhD;IAED;;;;;;;;;;OAUG;IACG,oBAAoB,CACxB,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CA6BlC;IAED;;;;;;;;;;OAUG;IACG,mBAAmB,CACvB,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,sBAAsB,CAAC,CA6BjC;CAqEF"}
|
package/dist/SocialService.js
CHANGED
|
@@ -196,6 +196,28 @@ const FollowResponseStruct = structType({
|
|
|
196
196
|
const UnfollowResponseStruct = structType({
|
|
197
197
|
unfollowed: array(ProfileSummaryStruct),
|
|
198
198
|
});
|
|
199
|
+
const BlockedProfileStruct = structType({
|
|
200
|
+
blockedAt: number(),
|
|
201
|
+
reason: nullable(string()),
|
|
202
|
+
profile: ProfileSummaryStruct,
|
|
203
|
+
});
|
|
204
|
+
const BlockedProfilesResponseStruct = structType({
|
|
205
|
+
items: array(BlockedProfileStruct),
|
|
206
|
+
cursor: nullable(string()),
|
|
207
|
+
});
|
|
208
|
+
const BlockedContentStruct = structType({
|
|
209
|
+
blockedAt: number(),
|
|
210
|
+
reason: nullable(string()),
|
|
211
|
+
type: enums(['comment', 'reply']),
|
|
212
|
+
id: string(),
|
|
213
|
+
text: string(),
|
|
214
|
+
createdAt: number(),
|
|
215
|
+
author: nullable(ProfileSummaryStruct),
|
|
216
|
+
});
|
|
217
|
+
const BlockedContentResponseStruct = structType({
|
|
218
|
+
items: array(BlockedContentStruct),
|
|
219
|
+
cursor: nullable(string()),
|
|
220
|
+
});
|
|
199
221
|
// ---------------------------------------------------------------------------
|
|
200
222
|
// Messenger types
|
|
201
223
|
// ---------------------------------------------------------------------------
|
|
@@ -218,6 +240,9 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
218
240
|
'optOutOfLeaderboard',
|
|
219
241
|
'optInToLeaderboard',
|
|
220
242
|
'refreshNotificationPreferencesCache',
|
|
243
|
+
'block',
|
|
244
|
+
'fetchBlockedProfiles',
|
|
245
|
+
'fetchBlockedContent',
|
|
221
246
|
];
|
|
222
247
|
// ---------------------------------------------------------------------------
|
|
223
248
|
// Service
|
|
@@ -864,6 +889,105 @@ export class SocialService extends BaseDataService {
|
|
|
864
889
|
},
|
|
865
890
|
});
|
|
866
891
|
}
|
|
892
|
+
/**
|
|
893
|
+
* Blocks a trader, swap comment, or reply for the current user.
|
|
894
|
+
*
|
|
895
|
+
* Calls `PUT ${baseUrl}/moderation/block`. Provide exactly one of
|
|
896
|
+
* `profileId`, `commentId`, or `replyId`. Blocking the same target again
|
|
897
|
+
* replaces `reason` when one is given. The caller is identified server-side
|
|
898
|
+
* from the JWT sub claim carried in the Authorization header.
|
|
899
|
+
*
|
|
900
|
+
* @param options - Options bag. Exactly one target, plus an optional reason.
|
|
901
|
+
* @param options.profileId - Profile id (UUID) of the trader to block.
|
|
902
|
+
* @param options.commentId - Swap comment to block.
|
|
903
|
+
* @param options.replyId - Comment reply to block.
|
|
904
|
+
* @param options.reason - Free-form reason stored on the block.
|
|
905
|
+
*/
|
|
906
|
+
async block(options) {
|
|
907
|
+
await this.fetchQuery({
|
|
908
|
+
queryKey: [`${this.name}:block`, options],
|
|
909
|
+
staleTime: 0,
|
|
910
|
+
queryFn: async () => {
|
|
911
|
+
const url = `${this.#v1Url}/moderation/block`;
|
|
912
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
913
|
+
const response = await fetch(url, {
|
|
914
|
+
method: 'PUT',
|
|
915
|
+
headers: { ...authHeaders, 'Content-Type': 'application/json' },
|
|
916
|
+
body: JSON.stringify(options),
|
|
917
|
+
});
|
|
918
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.BLOCK_FAILED);
|
|
919
|
+
return null;
|
|
920
|
+
},
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Fetches traders the current user has blocked.
|
|
925
|
+
*
|
|
926
|
+
* Calls `GET ${baseUrl}/moderation/blocks/profiles`. Results are most
|
|
927
|
+
* recently blocked first, 250 per page. The caller is identified
|
|
928
|
+
* server-side from the JWT sub claim carried in the Authorization header.
|
|
929
|
+
*
|
|
930
|
+
* @param options - Options bag.
|
|
931
|
+
* @param options.cursor - Cursor from the previous page. Omit for the first page.
|
|
932
|
+
* @returns The blocked profiles page.
|
|
933
|
+
*/
|
|
934
|
+
async fetchBlockedProfiles(options) {
|
|
935
|
+
const cursor = options?.cursor;
|
|
936
|
+
return await this.fetchQuery({
|
|
937
|
+
queryKey: [`${this.name}:fetchBlockedProfiles`, cursor ?? null],
|
|
938
|
+
staleTime: 0,
|
|
939
|
+
queryFn: async () => {
|
|
940
|
+
const url = new URL(`${this.#v1Url}/moderation/blocks/profiles`);
|
|
941
|
+
if (cursor) {
|
|
942
|
+
url.searchParams.append('cursor', cursor);
|
|
943
|
+
}
|
|
944
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
945
|
+
const response = await fetch(url.toString(), {
|
|
946
|
+
headers: authHeaders,
|
|
947
|
+
});
|
|
948
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.FETCH_BLOCKED_PROFILES_FAILED);
|
|
949
|
+
const blockedProfiles = (await response.json());
|
|
950
|
+
if (!is(blockedProfiles, BlockedProfilesResponseStruct)) {
|
|
951
|
+
throw new Error(SocialServiceErrorMessage.FETCH_BLOCKED_PROFILES_INVALID_RESPONSE);
|
|
952
|
+
}
|
|
953
|
+
return blockedProfiles;
|
|
954
|
+
},
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Fetches comments and replies the current user has blocked.
|
|
959
|
+
*
|
|
960
|
+
* Calls `GET ${baseUrl}/moderation/blocks/content`. Results are most
|
|
961
|
+
* recently blocked first, 250 per page. The caller is identified
|
|
962
|
+
* server-side from the JWT sub claim carried in the Authorization header.
|
|
963
|
+
*
|
|
964
|
+
* @param options - Options bag.
|
|
965
|
+
* @param options.cursor - Cursor from the previous page. Omit for the first page.
|
|
966
|
+
* @returns The blocked content page.
|
|
967
|
+
*/
|
|
968
|
+
async fetchBlockedContent(options) {
|
|
969
|
+
const cursor = options?.cursor;
|
|
970
|
+
return await this.fetchQuery({
|
|
971
|
+
queryKey: [`${this.name}:fetchBlockedContent`, cursor ?? null],
|
|
972
|
+
staleTime: 0,
|
|
973
|
+
queryFn: async () => {
|
|
974
|
+
const url = new URL(`${this.#v1Url}/moderation/blocks/content`);
|
|
975
|
+
if (cursor) {
|
|
976
|
+
url.searchParams.append('cursor', cursor);
|
|
977
|
+
}
|
|
978
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
979
|
+
const response = await fetch(url.toString(), {
|
|
980
|
+
headers: authHeaders,
|
|
981
|
+
});
|
|
982
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.FETCH_BLOCKED_CONTENT_FAILED);
|
|
983
|
+
const blockedContent = (await response.json());
|
|
984
|
+
if (!is(blockedContent, BlockedContentResponseStruct)) {
|
|
985
|
+
throw new Error(SocialServiceErrorMessage.FETCH_BLOCKED_CONTENT_INVALID_RESPONSE);
|
|
986
|
+
}
|
|
987
|
+
return blockedContent;
|
|
988
|
+
},
|
|
989
|
+
});
|
|
990
|
+
}
|
|
867
991
|
/**
|
|
868
992
|
* Shared helper for fetching open/closed positions.
|
|
869
993
|
*
|