1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-07 23:02:56 +03:00

Fix state_events.ts types (#4196)

* Fix state_events.ts types

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2024-05-10 11:55:44 +01:00
committed by GitHub
parent 2a716bd076
commit a25cdcecaa
3 changed files with 10 additions and 11 deletions

View File

@@ -45,14 +45,6 @@ export enum RestrictedAllowType {
RoomMembership = "m.room_membership", RoomMembership = "m.room_membership",
} }
export interface IJoinRuleEventContent {
join_rule: JoinRule; // eslint-disable-line camelcase
allow?: {
type: RestrictedAllowType;
room_id: string; // eslint-disable-line camelcase
}[];
}
export enum GuestAccess { export enum GuestAccess {
CanJoin = "can_join", CanJoin = "can_join",
Forbidden = "forbidden", Forbidden = "forbidden",

View File

@@ -15,7 +15,7 @@ limitations under the License.
*/ */
import { RoomType } from "./event"; import { RoomType } from "./event";
import { GuestAccess, HistoryVisibility, RestrictedAllowType } from "./partials"; import { GuestAccess, HistoryVisibility, JoinRule, RestrictedAllowType } from "./partials";
import { ImageInfo } from "./media"; import { ImageInfo } from "./media";
import { PolicyRecommendation } from "../models/invites-ignorer"; import { PolicyRecommendation } from "../models/invites-ignorer";
@@ -36,12 +36,18 @@ export interface RoomCreateEventContent {
} }
export interface RoomJoinRulesEventContent { export interface RoomJoinRulesEventContent {
join_rule: JoinRule;
allow?: { allow?: {
room_id: string; room_id: string;
type: RestrictedAllowType; type: RestrictedAllowType;
}[]; }[];
} }
/**
* @deprecated in favour of RoomJoinRulesEventContent
*/
export type IJoinRuleEventContent = RoomJoinRulesEventContent;
export interface RoomMemberEventContent { export interface RoomMemberEventContent {
avatar_url?: string; avatar_url?: string;
displayname?: string; displayname?: string;

View File

@@ -20,12 +20,13 @@ import { isNumber, removeHiddenChars } from "../utils";
import { EventType, UNSTABLE_MSC2716_MARKER } from "../@types/event"; import { EventType, UNSTABLE_MSC2716_MARKER } from "../@types/event";
import { IEvent, MatrixEvent, MatrixEventEvent } from "./event"; import { IEvent, MatrixEvent, MatrixEventEvent } from "./event";
import { MatrixClient } from "../client"; import { MatrixClient } from "../client";
import { GuestAccess, HistoryVisibility, IJoinRuleEventContent, JoinRule } from "../@types/partials"; import { GuestAccess, HistoryVisibility, JoinRule } from "../@types/partials";
import { TypedEventEmitter } from "./typed-event-emitter"; import { TypedEventEmitter } from "./typed-event-emitter";
import { Beacon, BeaconEvent, BeaconEventHandlerMap, getBeaconInfoIdentifier, BeaconIdentifier } from "./beacon"; import { Beacon, BeaconEvent, BeaconEventHandlerMap, getBeaconInfoIdentifier, BeaconIdentifier } from "./beacon";
import { TypedReEmitter } from "../ReEmitter"; import { TypedReEmitter } from "../ReEmitter";
import { M_BEACON, M_BEACON_INFO } from "../@types/beacon"; import { M_BEACON, M_BEACON_INFO } from "../@types/beacon";
import { KnownMembership } from "../@types/membership"; import { KnownMembership } from "../@types/membership";
import { RoomJoinRulesEventContent } from "../@types/state_events";
export interface IMarkerFoundOptions { export interface IMarkerFoundOptions {
/** Whether the timeline was empty before the marker event arrived in the /** Whether the timeline was empty before the marker event arrived in the
@@ -962,7 +963,7 @@ export class RoomState extends TypedEventEmitter<EmittedEvents, EventHandlerMap>
*/ */
public getJoinRule(): JoinRule { public getJoinRule(): JoinRule {
const joinRuleEvent = this.getStateEvents(EventType.RoomJoinRules, ""); const joinRuleEvent = this.getStateEvents(EventType.RoomJoinRules, "");
const joinRuleContent: Partial<IJoinRuleEventContent> = joinRuleEvent?.getContent() ?? {}; const joinRuleContent: Partial<RoomJoinRulesEventContent> = joinRuleEvent?.getContent() ?? {};
return joinRuleContent["join_rule"] || JoinRule.Invite; return joinRuleContent["join_rule"] || JoinRule.Invite;
} }