diff --git a/keyserver/src/endpoints.js b/keyserver/src/endpoints.js --- a/keyserver/src/endpoints.js +++ b/keyserver/src/endpoints.js @@ -63,7 +63,10 @@ updateUserAvatarResponder, } from './responders/user-responders.js'; import { codeVerificationResponder } from './responders/verification-responders.js'; -import { uploadDeletionResponder } from './uploads/uploads.js'; +import { + uploadMediaMetadataResponder, + uploadDeletionResponder, +} from './uploads/uploads.js'; const jsonEndpoints: { [id: Endpoint]: JSONResponder } = { create_account: { @@ -262,6 +265,10 @@ responder: updateUserAvatarResponder, requiredPolicies: baseLegalPolicies, }, + upload_media_metadata: { + responder: uploadMediaMetadataResponder, + requiredPolicies: baseLegalPolicies, + }, }; export { jsonEndpoints }; diff --git a/lib/actions/upload-actions.js b/lib/actions/upload-actions.js --- a/lib/actions/upload-actions.js +++ b/lib/actions/upload-actions.js @@ -2,9 +2,10 @@ import type { Shape } from '../types/core.js'; import type { + UploadMediaMetadataRequest, UploadMultimediaResult, Dimensions, -} from '../types/media-types.js'; +} from '../types/media-types'; import type { CallServerEndpoint } from '../utils/call-server-endpoint.js'; import type { UploadBlob } from '../utils/upload-blob.js'; @@ -19,6 +20,21 @@ encryptionKey?: string, }>; +const uploadMediaMetadata = + ( + callServerEndpoint: CallServerEndpoint, + ): ((input: UploadMediaMetadataRequest) => Promise) => + async input => { + const response = await callServerEndpoint('upload_media_metadata', input); + return { + id: response.id, + uri: response.uri, + mediaType: response.mediaType, + dimensions: response.dimensions, + loop: response.loop, + }; + }; + const uploadMultimedia = ( callServerEndpoint: CallServerEndpoint, @@ -84,6 +100,7 @@ export { uploadMultimedia, + uploadMediaMetadata, updateMultimediaMessageMediaActionType, deleteUpload, }; diff --git a/lib/types/endpoints.js b/lib/types/endpoints.js --- a/lib/types/endpoints.js +++ b/lib/types/endpoints.js @@ -87,6 +87,7 @@ SIWE_NONCE: 'siwe_nonce', SIWE_AUTH: 'siwe_auth', UPDATE_USER_AVATAR: 'update_user_avatar', + UPLOAD_MEDIA_METADATA: 'upload_media_metadata', }); type SocketPreferredEndpoint = $Values;