Basic call link join support
This commit is contained in:
parent
2bfb6e7481
commit
96b3413feb
75 changed files with 2438 additions and 509 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
import { debounce, omit } from 'lodash';
|
||||
|
||||
import { CallLinkRootKey } from '@signalapp/ringrtc';
|
||||
import type { LinkPreviewWithHydratedData } from '../types/message/LinkPreviews';
|
||||
import type {
|
||||
LinkPreviewImage,
|
||||
|
@ -28,6 +29,8 @@ import { imageToBlurHash } from '../util/imageToBlurHash';
|
|||
import { maybeParseUrl } from '../util/url';
|
||||
import { sniffImageMimeType } from '../util/sniffImageMimeType';
|
||||
import { drop } from '../util/drop';
|
||||
import { linkCallRoute } from '../util/signalRoutes';
|
||||
import { calling } from './calling';
|
||||
|
||||
const LINK_PREVIEW_TIMEOUT = 60 * SECOND;
|
||||
|
||||
|
@ -164,6 +167,7 @@ export async function addLinkPreview(
|
|||
window.reduxActions.linkPreviews.addLinkPreview(
|
||||
{
|
||||
url,
|
||||
isCallLink: false,
|
||||
},
|
||||
source,
|
||||
conversationId
|
||||
|
@ -220,6 +224,7 @@ export async function addLinkPreview(
|
|||
date: dropNull(result.date),
|
||||
domain: LinkPreview.getDomain(result.url),
|
||||
isStickerPack: LinkPreview.isStickerPack(result.url),
|
||||
isCallLink: LinkPreview.isCallLink(result.url),
|
||||
},
|
||||
source,
|
||||
conversationId
|
||||
|
@ -274,6 +279,7 @@ export function sanitizeLinkPreview(
|
|||
date: dropNull(item.date),
|
||||
domain: LinkPreview.getDomain(item.url),
|
||||
isStickerPack: LinkPreview.isStickerPack(item.url),
|
||||
isCallLink: LinkPreview.isCallLink(item.url),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -284,6 +290,7 @@ export function sanitizeLinkPreview(
|
|||
date: dropNull(item.date),
|
||||
domain: LinkPreview.getDomain(item.url),
|
||||
isStickerPack: LinkPreview.isStickerPack(item.url),
|
||||
isCallLink: LinkPreview.isCallLink(item.url),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -303,6 +310,9 @@ async function getPreview(
|
|||
if (LinkPreview.isGroupLink(url)) {
|
||||
return getGroupPreview(url, abortSignal);
|
||||
}
|
||||
if (LinkPreview.isCallLink(url)) {
|
||||
return getCallLinkPreview(url, abortSignal);
|
||||
}
|
||||
|
||||
// This is already checked elsewhere, but we want to be extra-careful.
|
||||
if (!LinkPreview.shouldPreviewHref(url)) {
|
||||
|
@ -563,3 +573,30 @@ async function getGroupPreview(
|
|||
url,
|
||||
};
|
||||
}
|
||||
|
||||
async function getCallLinkPreview(
|
||||
url: string,
|
||||
_abortSignal: Readonly<AbortSignal>
|
||||
): Promise<null | LinkPreviewResult> {
|
||||
const parsedUrl = linkCallRoute.fromUrl(url);
|
||||
if (parsedUrl == null) {
|
||||
throw new Error('Failed to parse call link URL');
|
||||
}
|
||||
|
||||
const callLinkRootKey = CallLinkRootKey.parse(parsedUrl.args.key);
|
||||
const callLinkState = await calling.readCallLink({ callLinkRootKey });
|
||||
if (!callLinkState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
url,
|
||||
title:
|
||||
callLinkState.name === ''
|
||||
? window.i18n('icu:calling__call-link-default-title')
|
||||
: callLinkState.name,
|
||||
description: window.i18n('icu:message--call-link-description'),
|
||||
image: undefined,
|
||||
date: null,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue