Skip to content

Commit 6ec200a

Browse files
authored
Stabilise MSC3765 (#4767)
* Stabilise MSC3765 Signed-off-by: Johannes Marbach <[email protected]> * Remove unstable content and hardcode property name --------- Signed-off-by: Johannes Marbach <[email protected]>
1 parent 19b1b90 commit 6ec200a

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

spec/unit/content-helpers.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ describe("Topic content helpers", () => {
196196
expect(makeTopicContent("pizza", "<b>pizza</b>")).toEqual({
197197
topic: "pizza",
198198
[M_TOPIC.name]: [
199-
{
200-
body: "pizza",
201-
mimetype: "text/plain",
202-
},
203199
{
204200
body: "<b>pizza</b>",
205201
mimetype: "text/html",
206202
},
203+
{
204+
body: "pizza",
205+
mimetype: "text/plain",
206+
},
207207
],
208208
});
209209
});

src/@types/topic.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
import { UnstableValue } from "../NamespacedValue.ts";
16+
import { NamespacedValue } from "../NamespacedValue.ts";
1717
import { type IMessageRendering } from "./extensible_events.ts";
1818

1919
/**
@@ -42,20 +42,17 @@ import { type IMessageRendering } from "./extensible_events.ts";
4242
/**
4343
* The event type for an m.topic event (in content)
4444
*/
45-
export const M_TOPIC = new UnstableValue("m.topic", "org.matrix.msc3765.topic");
45+
export const M_TOPIC = new NamespacedValue("m.topic");
4646

4747
/**
4848
* The event content for an m.topic event (in content)
4949
*/
5050
export type MTopicContent = IMessageRendering[];
5151

52-
type MTopicStable = { [M_TOPIC.altName]: MTopicContent };
53-
type MTopicUnstable = { [M_TOPIC.name]: MTopicContent };
54-
5552
/**
5653
* The event definition for an m.topic event (in content)
5754
*/
58-
export type MTopicEvent = (MTopicStable & MTopicUnstable) | MTopicStable | MTopicUnstable;
55+
export type MTopicEvent = { "m.topic": MTopicContent };
5956

6057
/**
6158
* The event content for an m.room.topic event

src/content-helpers.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,14 @@ export type MakeTopicContent = (topic: string | null | undefined, htmlTopic?: st
189189

190190
export const makeTopicContent: MakeTopicContent = (topic, htmlTopic) => {
191191
const renderings = [];
192-
if (isProvided(topic)) {
193-
renderings.push({ body: topic, mimetype: "text/plain" });
194-
}
192+
// Put HTML first because clients will render the first type in
193+
// the array that they understand
195194
if (isProvided(htmlTopic)) {
196195
renderings.push({ body: htmlTopic, mimetype: "text/html" });
197196
}
197+
if (isProvided(topic)) {
198+
renderings.push({ body: topic, mimetype: "text/plain" });
199+
}
198200
return { topic, [M_TOPIC.name]: renderings };
199201
};
200202

0 commit comments

Comments
 (0)