Page MenuHomePhabricator

D11995.id41014.diff
No OneTemporary

D11995.id41014.diff

diff --git a/keyserver/src/endpoints.js b/keyserver/src/endpoints.js
--- a/keyserver/src/endpoints.js
+++ b/keyserver/src/endpoints.js
@@ -15,6 +15,7 @@
setThreadUnreadStatusValidator,
updateActivityResponderInputValidator,
} from './responders/activity-responders.js';
+import { fetchCommunityInfosResponder } from './responders/community-responders.js';
import {
deviceTokenUpdateResponder,
deviceTokenUpdateRequestInputValidator,
@@ -483,6 +484,11 @@
inputValidator: ignoredArgumentValidator,
policies: [],
},
+ fetch_community_infos: {
+ responder: fetchCommunityInfosResponder,
+ inputValidator: ignoredArgumentValidator,
+ policies: baseLegalPolicies,
+ },
create_or_update_farcaster_channel_tag: {
responder: createOrUpdateFarcasterChannelTagResponder,
inputValidator: 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,21 @@
+// @flow
+
+import type { FetchCommunityInfosResponse } from 'lib/types/community-types.js';
+
+import { fetchCommunityInfos } from '../fetchers/community-fetchers.js';
+import { Viewer } from '../session/viewer.js';
+
+async function fetchCommunityInfosResponder(
+ viewer: Viewer,
+): Promise<FetchCommunityInfosResponse> {
+ const fetchedCommunities = await fetchCommunityInfos(viewer);
+
+ const communityInfos = fetchedCommunities.map(community => ({
+ id: community.id,
+ farcasterChannelID: community.farcasterChannelID,
+ }));
+
+ return { communityInfos };
+}
+
+export { 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
@@ -111,6 +111,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',
diff --git a/lib/types/validators/community-validators.js b/lib/types/validators/community-validators.js
new file mode 100644
--- /dev/null
+++ b/lib/types/validators/community-validators.js
@@ -0,0 +1,16 @@
+// @flow
+
+import t, { type TInterface } from 'tcomb';
+
+import { tShape } from '../../utils/validation-utils.js';
+import {
+ serverCommunityInfoValidator,
+ type FetchCommunityInfosResponse,
+} from '../community-types.js';
+
+const fetchCommunityInfosResponseValidator: TInterface<FetchCommunityInfosResponse> =
+ tShape({
+ communityInfos: t.list(serverCommunityInfoValidator),
+ });
+
+export { fetchCommunityInfosResponseValidator };
diff --git a/lib/types/validators/endpoint-validators.js b/lib/types/validators/endpoint-validators.js
--- a/lib/types/validators/endpoint-validators.js
+++ b/lib/types/validators/endpoint-validators.js
@@ -2,6 +2,7 @@
import t from 'tcomb';
+import { fetchCommunityInfosResponseValidator } from './community-validators.js';
import {
saveEntryResponseValidator,
deltaEntryInfosResultValidator,
@@ -168,6 +169,7 @@
validator: getOlmSessionInitializationDataResponseValidator,
},
version: { validator: versionResponseValidator },
+ fetch_community_infos: { validator: fetchCommunityInfosResponseValidator },
create_or_update_farcaster_channel_tag: {
validator: createOrUpdateFarcasterChannelTagResponseValidator,
},

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 9:02 AM (15 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2681245
Default Alt Text
D11995.id41014.diff (5 KB)

Event Timeline