Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix regressions around media uploads failing and causing soft crashes #9549

Merged
merged 5 commits into from
Nov 7, 2022
Merged
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
4 changes: 2 additions & 2 deletions src/Notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ export const Notifier = {
return null;
}

if (!content.url) {
logger.warn(`${roomId} has custom notification sound event, but no url key`);
if (typeof content.url !== "string") {
logger.warn(`${roomId} has custom notification sound event, but no url string`);
return null;
}

Expand Down
209 changes: 0 additions & 209 deletions src/components/views/settings/ChangeAvatar.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default class NotificationsSettingsTab extends React.Component<IProps, IS
type = "audio/ogg";
}

const url = await MatrixClientPeg.get().uploadContent(
const { content_uri: url } = await MatrixClientPeg.get().uploadContent(
this.state.uploadedFile, {
type,
},
Expand Down
9 changes: 5 additions & 4 deletions src/components/views/spaces/SpaceSettingsGeneralTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ const SpaceSettingsGeneralTab = ({ matrixClient: cli, space, onFinished }: IProp

const onSave = async () => {
setBusy(true);
const promises = [];
const promises: Promise<unknown>[] = [];

if (avatarChanged) {
if (newAvatar) {
promises.push(cli.sendStateEvent(space.roomId, EventType.RoomAvatar, {
url: await cli.uploadContent(newAvatar),
}, ""));
promises.push((async () => {
const { content_uri: url } = await cli.uploadContent(newAvatar);
await cli.sendStateEvent(space.roomId, EventType.RoomAvatar, { url }, "");
})());
} else {
promises.push(cli.sendStateEvent(space.roomId, EventType.RoomAvatar, {}, ""));
}
Expand Down
2 changes: 0 additions & 2 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1283,8 +1283,6 @@
"This bridge is managed by <user />.": "This bridge is managed by <user />.",
"Workspace: <networkLink/>": "Workspace: <networkLink/>",
"Channel: <channelLink/>": "Channel: <channelLink/>",
"Failed to upload profile picture!": "Failed to upload profile picture!",
"Upload new:": "Upload new:",
"No display name": "No display name",
"Warning!": "Warning!",
"Changing your password on this homeserver will cause all of your other devices to be signed out. This will delete the message encryption keys stored on them, and may make encrypted chat history unreadable.": "Changing your password on this homeserver will cause all of your other devices to be signed out. This will delete the message encryption keys stored on them, and may make encrypted chat history unreadable.",
Expand Down
9 changes: 9 additions & 0 deletions test/Notifier-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ describe("Notifier", () => {
});
});

describe("getSoundForRoom", () => {
it("should not explode if given invalid url", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation((name: string) => {
return { url: { content_uri: "foobar" } };
});
expect(Notifier.getSoundForRoom("!roomId:server")).toBeNull();
});
});

describe("_playAudioNotification", () => {
it.each([
{ event: { is_silenced: true }, count: 0 },
Expand Down