From 6f1f8a2ac735e45d916164c9bb45e470cc2e7ae2 Mon Sep 17 00:00:00 2001 From: Jana Naumoska Date: Tue, 19 May 2026 04:27:09 +0200 Subject: [PATCH 1/2] Add get or create follow and unfollow endpoints and fix generate command --- generate-openapi.sh | 6 ++- src/gen/feeds/FeedsApi.ts | 63 ++++++++++++++++++++++++++++++ src/gen/model-decoders/decoders.ts | 14 +++++++ src/gen/models/index.ts | 54 +++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 1 deletion(-) diff --git a/generate-openapi.sh b/generate-openapi.sh index e790a11..0144882 100755 --- a/generate-openapi.sh +++ b/generate-openapi.sh @@ -6,6 +6,10 @@ CHAT_DIR="../chat" rm -rf $OUTPUT_DIR -( cd $CHAT_DIR ; make openapi ; go run ./cmd/chat-manager openapi generate-client --language ts --spec ./releases/v2/serverside-api.yaml --output $OUTPUT_DIR ) +# `make openapi` builds the chat-manager binary into ./build/ and regenerates +# the spec files under ./releases/v2/. Reuse the built binary instead of +# `go run`, which broke when chat-manager moved to projects/chat-manager/ +# (its own module under the monorepo restructure). +( cd $CHAT_DIR ; make openapi ; ./build/chat-manager openapi generate-client --language ts --spec ./releases/v2/serverside-api.yaml --output $OUTPUT_DIR ) yarn lint:gen \ No newline at end of file diff --git a/src/gen/feeds/FeedsApi.ts b/src/gen/feeds/FeedsApi.ts index 2fe91ab..52404fd 100644 --- a/src/gen/feeds/FeedsApi.ts +++ b/src/gen/feeds/FeedsApi.ts @@ -67,6 +67,9 @@ import { GetOrCreateFeedResponse, GetOrCreateFeedViewRequest, GetOrCreateFeedViewResponse, + GetOrCreateFollowResponse, + GetOrCreateUnfollowRequest, + GetOrCreateUnfollowResponse, ListFeedGroupsResponse, ListFeedViewsResponse, ListFeedVisibilitiesResponse, @@ -2568,6 +2571,39 @@ export class FeedsApi { return { ...response.body, metadata: response.metadata }; } + async getOrCreateFollow( + request: FollowRequest, + ): Promise> { + const body = { + source: request?.source, + target: request?.target, + activity_copy_limit: request?.activity_copy_limit, + copy_custom_to_notification: request?.copy_custom_to_notification, + create_notification_activity: request?.create_notification_activity, + create_users: request?.create_users, + enrich_own_fields: request?.enrich_own_fields, + push_preference: request?.push_preference, + skip_push: request?.skip_push, + status: request?.status, + custom: request?.custom, + }; + + const response = await this.apiClient.sendRequest< + StreamResponse + >( + 'POST', + '/api/v2/feeds/follows/upsert', + undefined, + undefined, + body, + 'application/json', + ); + + decoders.GetOrCreateFollowResponse?.(response.body); + + return { ...response.body, metadata: response.metadata }; + } + async unfollow(request: { source: string; target: string; @@ -2804,6 +2840,33 @@ export class FeedsApi { return { ...response.body, metadata: response.metadata }; } + async getOrCreateUnfollow( + request: GetOrCreateUnfollowRequest, + ): Promise> { + const body = { + source: request?.source, + target: request?.target, + delete_notification_activity: request?.delete_notification_activity, + enrich_own_fields: request?.enrich_own_fields, + keep_history: request?.keep_history, + }; + + const response = await this.apiClient.sendRequest< + StreamResponse + >( + 'POST', + '/api/v2/feeds/unfollow/upsert', + undefined, + undefined, + body, + 'application/json', + ); + + decoders.GetOrCreateUnfollowResponse?.(response.body); + + return { ...response.body, metadata: response.metadata }; + } + async deleteFeedUserData( request: DeleteFeedUserDataRequest & { user_id: string }, ): Promise> { diff --git a/src/gen/model-decoders/decoders.ts b/src/gen/model-decoders/decoders.ts index 7395c23..e17a9ea 100644 --- a/src/gen/model-decoders/decoders.ts +++ b/src/gen/model-decoders/decoders.ts @@ -2767,6 +2767,20 @@ decoders.GetOrCreateFeedViewResponse = (input?: Record) => { return decode(typeMappings, input); }; +decoders.GetOrCreateFollowResponse = (input?: Record) => { + const typeMappings: TypeMapping = { + follow: { type: 'FollowResponse', isSingle: true }, + }; + return decode(typeMappings, input); +}; + +decoders.GetOrCreateUnfollowResponse = (input?: Record) => { + const typeMappings: TypeMapping = { + follow: { type: 'FollowResponse', isSingle: true }, + }; + return decode(typeMappings, input); +}; + decoders.GetPushTemplatesResponse = (input?: Record) => { const typeMappings: TypeMapping = { templates: { type: 'PushTemplateResponse', isSingle: false }, diff --git a/src/gen/models/index.ts b/src/gen/models/index.ts index 27e95de..a41e1ed 100644 --- a/src/gen/models/index.ts +++ b/src/gen/models/index.ts @@ -11165,6 +11165,60 @@ export interface GetOrCreateFeedViewResponse { feed_view: FeedViewResponse; } +export interface GetOrCreateFollowResponse { + /** + * True if the follow was newly created by this request; false if it already existed + */ + created: boolean; + + duration: string; + + follow: FollowResponse; + + /** + * Whether a notification activity was successfully created (only set when the follow was newly created) + */ + notification_created?: boolean; +} + +export interface GetOrCreateUnfollowRequest { + /** + * Fully qualified ID of the source feed + */ + source: string; + + /** + * Fully qualified ID of the target feed + */ + target: string; + + /** + * Whether to delete the corresponding notification activity (default: false) + */ + delete_notification_activity?: boolean; + + /** + * If true, enriches the follow's source_feed and target_feed with own_* fields (own_follows, own_followings, own_capabilities, own_membership). Defaults to false for performance. + */ + enrich_own_fields?: boolean; + + /** + * When true, activities from the unfollowed feed will remain in the source feed's timeline (default: false) + */ + keep_history?: boolean; +} + +export interface GetOrCreateUnfollowResponse { + /** + * True if a follow was found and removed by this request; false if no follow existed + */ + deleted: boolean; + + duration: string; + + follow?: FollowResponse; +} + export interface GetPushTemplatesResponse { /** * Duration of the request in milliseconds From d6fd25a562f2f8ae459f61d50e4e701a44791108 Mon Sep 17 00:00:00 2001 From: Jana Naumoska Date: Tue, 19 May 2026 04:29:11 +0200 Subject: [PATCH 2/2] Remove comment --- generate-openapi.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/generate-openapi.sh b/generate-openapi.sh index 0144882..d657c58 100755 --- a/generate-openapi.sh +++ b/generate-openapi.sh @@ -6,10 +6,6 @@ CHAT_DIR="../chat" rm -rf $OUTPUT_DIR -# `make openapi` builds the chat-manager binary into ./build/ and regenerates -# the spec files under ./releases/v2/. Reuse the built binary instead of -# `go run`, which broke when chat-manager moved to projects/chat-manager/ -# (its own module under the monorepo restructure). ( cd $CHAT_DIR ; make openapi ; ./build/chat-manager openapi generate-client --language ts --spec ./releases/v2/serverside-api.yaml --output $OUTPUT_DIR ) -yarn lint:gen \ No newline at end of file +yarn lint:gen