Page MenuHomePhorge

D13778.1768857163.diff
No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None

D13778.1768857163.diff

diff --git a/keyserver/src/creators/farcaster-channel-tag-creator.js b/keyserver/src/creators/farcaster-channel-tag-creator.js
--- a/keyserver/src/creators/farcaster-channel-tag-creator.js
+++ b/keyserver/src/creators/farcaster-channel-tag-creator.js
@@ -3,6 +3,10 @@
import uuid from 'uuid';
import { farcasterChannelTagBlobHash } from 'lib/shared/community-utils.js';
+import {
+ hasMinCodeVersion,
+ NEXT_CODE_VERSION,
+} from 'lib/shared/version-utils.js';
import type {
CreateOrUpdateFarcasterChannelTagRequest,
CreateOrUpdateFarcasterChannelTagResponse,
@@ -17,6 +21,7 @@
MYSQL_DUPLICATE_ENTRY_FOR_KEY_ERROR_CODE,
} from '../database/database.js';
import { fetchCommunityInfos } from '../fetchers/community-fetchers.js';
+import { fetchServerThreadInfos } from '../fetchers/thread-fetchers.js';
import { checkThreadPermission } from '../fetchers/thread-permission-fetchers.js';
import {
uploadBlobKeyserverWrapper,
@@ -26,7 +31,9 @@
type BlobDownloadResult,
} from '../services/blob.js';
import { Viewer } from '../session/viewer.js';
+import { updateThread } from '../updaters/thread-updaters.js';
import { thisKeyserverID } from '../user/identity.js';
+import { neynarClient } from '../utils/fc-cache.js';
import { getAndAssertKeyserverURLFacts } from '../utils/urls.js';
async function createOrUpdateFarcasterChannelTag(
@@ -130,9 +137,65 @@
throw new ServerError('invalid_parameters');
}
+ const neynarChannelDescriptionPromise = (async () => {
+ if (!neynarClient) {
+ return '';
+ }
+ const channelInfo = await neynarClient?.fetchFarcasterChannelByID(
+ request.farcasterChannelID,
+ );
+ return channelInfo?.description ?? '';
+ })();
+
+ const [fcChannelDescription, serverThreadInfos] = await Promise.all([
+ neynarChannelDescriptionPromise,
+ fetchServerThreadInfos({ threadID: request.commCommunityID }),
+ ]);
+
+ const threadInfo = serverThreadInfos.threadInfos[request.commCommunityID];
+ if (!threadInfo) {
+ return {
+ commCommunityID: request.commCommunityID,
+ farcasterChannelID: request.farcasterChannelID,
+ };
+ }
+ const { avatar, description } = threadInfo;
+ if (avatar && description) {
+ return {
+ commCommunityID: request.commCommunityID,
+ farcasterChannelID: request.farcasterChannelID,
+ };
+ }
+
+ let changes = {};
+ if (!avatar) {
+ changes = { ...changes, avatar: { type: 'farcaster' } };
+ }
+ if (!description) {
+ changes = { ...changes, description: fcChannelDescription };
+ }
+
+ const changeThreadSettingsResult = await updateThread(viewer, {
+ threadID: request.commCommunityID,
+ changes,
+ });
+
+ if (
+ !hasMinCodeVersion(viewer.platformDetails, {
+ native: NEXT_CODE_VERSION,
+ web: NEXT_CODE_VERSION,
+ })
+ ) {
+ return {
+ commCommunityID: request.commCommunityID,
+ farcasterChannelID: request.farcasterChannelID,
+ };
+ }
+
return {
commCommunityID: request.commCommunityID,
farcasterChannelID: request.farcasterChannelID,
+ ...changeThreadSettingsResult,
};
}
diff --git a/lib/actions/community-actions.js b/lib/actions/community-actions.js
--- a/lib/actions/community-actions.js
+++ b/lib/actions/community-actions.js
@@ -99,12 +99,7 @@
requests,
);
- const response = responses[keyserverID];
-
- return {
- commCommunityID: response.commCommunityID,
- farcasterChannelID: response.farcasterChannelID,
- };
+ return responses[keyserverID];
};
function useCreateOrUpdateFarcasterChannelTag(): (
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
@@ -2,6 +2,8 @@
import t, { type TInterface } from 'tcomb';
+import type { RawMessageInfo } from './message-types.js';
+import type { ServerUpdateInfo } from './update-types.js';
import { tID, tShape } from '../utils/validation-utils.js';
export type CommunityInfo = {
@@ -58,6 +60,10 @@
export type CreateOrUpdateFarcasterChannelTagResponse = {
+commCommunityID: string,
+farcasterChannelID: string,
+ +updatesResult?: ?{
+ +newUpdates: $ReadOnlyArray<ServerUpdateInfo>,
+ },
+ +newMessageInfos?: ?$ReadOnlyArray<RawMessageInfo>,
};
export type DeleteFarcasterChannelTagRequest = {
diff --git a/lib/types/validators/farcaster-channel-tag-validators.js b/lib/types/validators/farcaster-channel-tag-validators.js
--- a/lib/types/validators/farcaster-channel-tag-validators.js
+++ b/lib/types/validators/farcaster-channel-tag-validators.js
@@ -4,9 +4,24 @@
import { tShape, tID } from '../../utils/validation-utils.js';
import type { CreateOrUpdateFarcasterChannelTagResponse } from '../community-types';
+import { rawMessageInfoValidator } from '../message-types.js';
+import {
+ serverUpdateInfoValidator,
+ type ServerUpdateInfo,
+} from '../update-types.js';
+
+const updatesResultValidator: TInterface<{
+ +newUpdates: $ReadOnlyArray<ServerUpdateInfo>,
+}> = tShape<{
+ +newUpdates: $ReadOnlyArray<ServerUpdateInfo>,
+}>({
+ newUpdates: t.list(serverUpdateInfoValidator),
+});
export const createOrUpdateFarcasterChannelTagResponseValidator: TInterface<CreateOrUpdateFarcasterChannelTagResponse> =
tShape<CreateOrUpdateFarcasterChannelTagResponse>({
commCommunityID: tID,
farcasterChannelID: t.String,
+ newMessageInfos: t.maybe(t.list(rawMessageInfoValidator)),
+ updatesResult: t.maybe(updatesResultValidator),
});

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 19, 9:12 PM (11 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5958167
Default Alt Text
D13778.1768857163.diff (5 KB)

Event Timeline