Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ devAssets
*.tfbackend
!*.tfbackend.example
crash.log
build.sh
2 changes: 1 addition & 1 deletion knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"interface": true,
"type": true
},
"ignoreDependencies": ["buffer", "@element-hq/element-call-embedded", "workbox-precaching"],
"ignoreDependencies": ["buffer", "@sableclient/sable-call-embedded", "workbox-precaching"],
"ignoreBinaries": ["knope"],
"rules": {
"exports": "off",
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
},
"devDependencies": {
"@cloudflare/vite-plugin": "^1.26.0",
"@element-hq/element-call-embedded": "0.16.3",
"@sableclient/sable-call-embedded": "1.0.2",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@eslint/compat": "2.0.2",
"@eslint/js": "9.39.3",
Expand Down
2 changes: 2 additions & 0 deletions src/app/plugins/call/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export function getCallCapabilities(
capabilities.add(MatrixCapabilities.MSC3846TurnServers);
capabilities.add(MatrixCapabilities.MSC4157SendDelayedEvent);
capabilities.add(MatrixCapabilities.MSC4157UpdateDelayedEvent);
capabilities.add('moe.sable.thumbnails');
capabilities.add('moe.sable.media_proxy');
capabilities.add(`org.matrix.msc2762.timeline:${roomId}`);
capabilities.add(`org.matrix.msc2762.state:${roomId}`);

Expand Down
14 changes: 14 additions & 0 deletions src/sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@
return;
}

// Since widgets like element call have their own client ids,
// we need this logic. We just go through the sessions list and get a session
// with the right base url. Media requests to a homeserver simply are fine with any account
// on the homeserver authenticating it, so this is fine. But it can be technically wrong.
// If you have two tabs for different users on the same homeserver, it might authenticate
// as the wrong one.
// Thus any logic in the future which cares about which user is authenticating the request
// might break this. Also, again, it is technically wrong.
const byBaseUrl = [...sessions.values()].find((s) => validMediaRequest(url, s.baseUrl));
if (byBaseUrl) {
event.respondWith(fetch(url, { ...fetchConfig(byBaseUrl.accessToken), redirect }));
return;
}

event.respondWith(
requestSessionWithTimeout(clientId).then((s) => {
if (s && validMediaRequest(url, s.baseUrl)) {
Expand Down Expand Up @@ -296,20 +310,20 @@
// because iOS Safari PWA often returns empty or stale results from matchAll().
const hasVisibleClient =
appIsVisible || clients.some((client) => client.visibilityState === 'visible');
console.debug(

Check warning on line 313 in src/sw.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement
'[SW push] appIsVisible:',
appIsVisible,
'| clients:',
clients.map((c) => ({ url: c.url, visibility: c.visibilityState }))
);
console.debug('[SW push] hasVisibleClient:', hasVisibleClient);

Check warning on line 319 in src/sw.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement
if (hasVisibleClient) {
console.debug('[SW push] suppressing OS notification — app is visible');

Check warning on line 321 in src/sw.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement
return;
}

const pushData = event.data.json();
console.debug('[SW push] raw payload:', JSON.stringify(pushData, null, 2));

Check warning on line 326 in src/sw.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement

try {
if (typeof pushData?.unread === 'number') {
Expand Down Expand Up @@ -349,8 +363,8 @@
const pushEventId: string | undefined = data?.event_id ?? undefined;
const isInvite = data?.content?.membership === 'invite';

console.debug('[SW notificationclick] notification data:', JSON.stringify(data, null, 2));

Check warning on line 366 in src/sw.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement
console.debug('[SW notificationclick] resolved fields:', {

Check warning on line 367 in src/sw.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement
pushUserId,
pushRoomId,
pushEventId,
Expand Down Expand Up @@ -382,7 +396,7 @@
targetUrl = new URL('inbox/notifications/', scope).href;
}

console.debug('[SW notificationclick] targetUrl:', targetUrl);

Check warning on line 399 in src/sw.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement

event.waitUntil(
(async () => {
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const isReleaseTag = (() => {
const copyFiles = {
targets: [
{
src: 'node_modules/@element-hq/element-call-embedded/dist/*',
src: 'node_modules/@sableclient/sable-call-embedded/dist/*',
dest: 'public/element-call',
},
{
Expand Down
Loading