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

Commit 02a0fad

Browse files
t3chguygithub-actions[bot]
authored andcommitted
Fix regressions around media uploads failing and causing soft crashes (#9549)
(cherry picked from commit 77764d8)
1 parent e58681e commit 02a0fad

File tree

6 files changed

+17
-218
lines changed

6 files changed

+17
-218
lines changed

src/Notifier.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ export const Notifier = {
161161
return null;
162162
}
163163

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

src/components/views/settings/ChangeAvatar.tsx

Lines changed: 0 additions & 209 deletions
This file was deleted.

src/components/views/settings/tabs/room/NotificationSettingsTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export default class NotificationsSettingsTab extends React.Component<IProps, IS
119119
type = "audio/ogg";
120120
}
121121

122-
const url = await MatrixClientPeg.get().uploadContent(
122+
const { content_uri: url } = await MatrixClientPeg.get().uploadContent(
123123
this.state.uploadedFile, {
124124
type,
125125
},

src/components/views/spaces/SpaceSettingsGeneralTab.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ const SpaceSettingsGeneralTab = ({ matrixClient: cli, space, onFinished }: IProp
6161

6262
const onSave = async () => {
6363
setBusy(true);
64-
const promises = [];
64+
const promises: Promise<unknown>[] = [];
6565

6666
if (avatarChanged) {
6767
if (newAvatar) {
68-
promises.push(cli.sendStateEvent(space.roomId, EventType.RoomAvatar, {
69-
url: await cli.uploadContent(newAvatar),
70-
}, ""));
68+
promises.push((async () => {
69+
const { content_uri: url } = await cli.uploadContent(newAvatar);
70+
await cli.sendStateEvent(space.roomId, EventType.RoomAvatar, { url }, "");
71+
})());
7172
} else {
7273
promises.push(cli.sendStateEvent(space.roomId, EventType.RoomAvatar, {}, ""));
7374
}

src/i18n/strings/en_EN.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,8 +1283,6 @@
12831283
"This bridge is managed by <user />.": "This bridge is managed by <user />.",
12841284
"Workspace: <networkLink/>": "Workspace: <networkLink/>",
12851285
"Channel: <channelLink/>": "Channel: <channelLink/>",
1286-
"Failed to upload profile picture!": "Failed to upload profile picture!",
1287-
"Upload new:": "Upload new:",
12881286
"No display name": "No display name",
12891287
"Warning!": "Warning!",
12901288
"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.",

test/Notifier-test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,15 @@ describe("Notifier", () => {
232232
});
233233
});
234234

235+
describe("getSoundForRoom", () => {
236+
it("should not explode if given invalid url", () => {
237+
jest.spyOn(SettingsStore, "getValue").mockImplementation((name: string) => {
238+
return { url: { content_uri: "foobar" } };
239+
});
240+
expect(Notifier.getSoundForRoom("!roomId:server")).toBeNull();
241+
});
242+
});
243+
235244
describe("_playAudioNotification", () => {
236245
it.each([
237246
{ event: { is_silenced: true }, count: 0 },

0 commit comments

Comments
 (0)