Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3342169
D13778.id45359.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13778.id45359.diff
View Options
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
@@ -10,6 +10,7 @@
import { threadPermissions } from 'lib/types/thread-permission-types.js';
import type { BlobOperationResult } from 'lib/utils/blob-service.js';
import { ServerError } from 'lib/utils/errors.js';
+import { ignorePromiseRejections } from 'lib/utils/promises.js';
import {
dbQuery,
@@ -17,6 +18,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 +28,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,6 +134,50 @@
throw new ServerError('invalid_parameters');
}
+ // In the background, we fetch information about the community thread and
+ // corresponding Farcaster channel. If the thread's avatar or description has
+ // not already been set, we set them to the values from the channel.
+ ignorePromiseRejections(
+ (async () => {
+ const neynarChannelDescriptionPromise = (async () => {
+ if (!neynarClient) {
+ return '';
+ }
+ const channelInfo = await neynarClient?.fetchFarcasterChannelByID(
+ request.farcasterChannelID,
+ );
+ if (!channelInfo) {
+ return '';
+ }
+ return channelInfo.description;
+ })();
+
+ const [fcChannelDescription, serverThreadInfos] = await Promise.all([
+ neynarChannelDescriptionPromise,
+ fetchServerThreadInfos({ threadID: request.commCommunityID }),
+ ]);
+
+ const { avatar, description } =
+ serverThreadInfos.threadInfos[request.commCommunityID];
+ if (avatar && description) {
+ return;
+ }
+
+ let changes = {};
+ if (!avatar) {
+ changes = { ...changes, avatar: { type: 'farcaster' } };
+ }
+ if (!description) {
+ changes = { ...changes, description: fcChannelDescription };
+ }
+
+ await updateThread(viewer, {
+ threadID: request.commCommunityID,
+ changes,
+ });
+ })(),
+ );
+
return {
commCommunityID: request.commCommunityID,
farcasterChannelID: request.farcasterChannelID,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 12:41 AM (15 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2566899
Default Alt Text
D13778.id45359.diff (2 KB)
Attached To
Mode
D13778: set farcaster avatar and channel description in db during createOrUpdateFarcasterChannelTag
Attached
Detach File
Event Timeline
Log In to Comment