Page MenuHomePhabricator

D11995.id40083.diff
No OneTemporary

D11995.id40083.diff

diff --git a/keyserver/src/endpoints.js b/keyserver/src/endpoints.js
--- a/keyserver/src/endpoints.js
+++ b/keyserver/src/endpoints.js
@@ -70,6 +70,10 @@
setThreadUnreadStatusValidator,
updateActivityResponderInputValidator,
} from './responders/activity-responders.js';
+import {
+ fetchCommunityInfosResponder,
+ fetchCommunityInfosResponseValidator,
+} from './responders/community-responders.js';
import {
deviceTokenUpdateResponder,
deviceTokenUpdateRequestInputValidator,
@@ -592,6 +596,12 @@
versionResponseValidator,
[],
),
+ fetch_community_infos: createJSONResponder(
+ fetchCommunityInfosResponder,
+ ignoredArgumentValidator,
+ fetchCommunityInfosResponseValidator,
+ baseLegalPolicies,
+ ),
create_or_update_farcaster_channel_tag: createJSONResponder(
createOrUpdateFarcasterChannelTagResponder,
createOrUpdateFarcasterChannelTagInputValidator,
diff --git a/keyserver/src/fetchers/community-fetchers.js b/keyserver/src/fetchers/community-fetchers.js
--- a/keyserver/src/fetchers/community-fetchers.js
+++ b/keyserver/src/fetchers/community-fetchers.js
@@ -1,13 +1,12 @@
// @flow
-import type { CommunityInfo } from 'lib/types/community-types.js';
+import type { ServerCommunityInfo } from 'lib/types/community-types.js';
import { dbQuery, SQL } from '../database/database.js';
import { Viewer } from '../session/viewer.js';
type ServerCommunityInfoWithHolder = $ReadOnly<{
- ...CommunityInfo,
- +id: string,
+ ...ServerCommunityInfo,
+blobHolder: ?string,
}>;
diff --git a/keyserver/src/responders/community-responders.js b/keyserver/src/responders/community-responders.js
new file mode 100644
--- /dev/null
+++ b/keyserver/src/responders/community-responders.js
@@ -0,0 +1,32 @@
+// @flow
+
+import t, { type TInterface } from 'tcomb';
+
+import {
+ serverCommunityInfoValidator,
+ type FetchCommunityInfosResponse,
+} from 'lib/types/community-types.js';
+import { tShape } from 'lib/utils/validation-utils.js';
+
+import { fetchCommunityInfos } from '../fetchers/community-fetchers.js';
+import { Viewer } from '../session/viewer.js';
+
+const fetchCommunityInfosResponseValidator: TInterface<FetchCommunityInfosResponse> =
+ tShape({
+ communityInfos: t.list(serverCommunityInfoValidator),
+ });
+
+async function fetchCommunityInfosResponder(
+ viewer: Viewer,
+): Promise<FetchCommunityInfosResponse> {
+ const communitiesWithHolder = await fetchCommunityInfos(viewer);
+
+ const communityInfos = communitiesWithHolder.map(community => ({
+ id: community.id,
+ farcasterChannelID: community.farcasterChannelID,
+ }));
+
+ return { communityInfos };
+}
+
+export { fetchCommunityInfosResponseValidator, fetchCommunityInfosResponder };
diff --git a/lib/types/community-types.js b/lib/types/community-types.js
--- a/lib/types/community-types.js
+++ b/lib/types/community-types.js
@@ -1,5 +1,9 @@
// @flow
+import t, { type TInterface } from 'tcomb';
+
+import { tID, tShape } from '../utils/validation-utils.js';
+
export type CommunityInfo = {
+farcasterChannelID: ?string,
};
@@ -15,6 +19,21 @@
+newCommunityInfo: CommunityInfo,
};
+export type ServerCommunityInfo = {
+ +id: string,
+ +farcasterChannelID: ?string,
+};
+
+export const serverCommunityInfoValidator: TInterface<ServerCommunityInfo> =
+ tShape<ServerCommunityInfo>({
+ id: tID,
+ farcasterChannelID: t.maybe(t.String),
+ });
+
+export type FetchCommunityInfosResponse = {
+ +communityInfos: $ReadOnlyArray<ServerCommunityInfo>,
+};
+
export type CreateOrUpdateFarcasterChannelTagRequest = {
+commCommunityID: string,
+farcasterChannelID: string,
diff --git a/lib/types/endpoints.js b/lib/types/endpoints.js
--- a/lib/types/endpoints.js
+++ b/lib/types/endpoints.js
@@ -112,6 +112,7 @@
SEARCH_MESSAGES: 'search_messages',
GET_OLM_SESSION_INITIALIZATION_DATA: 'get_olm_session_initialization_data',
VERSION: 'version',
+ FETCH_COMMUNITY_INFOS: 'fetch_community_infos',
CREATE_OR_UPDATE_FARCASTER_CHANNEL_TAG:
'create_or_update_farcaster_channel_tag',
DELETE_FARCASTER_CHANNEL_TAG: 'delete_farcaster_channel_tag',

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 12:40 AM (17 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2681257
Default Alt Text
D11995.id40083.diff (4 KB)

Event Timeline