mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
logic for whether a key should be shared by membership and h. visibility
This commit is contained in:
parent
f337940202
commit
86c0e9e669
@ -69,3 +69,28 @@ export function createRoomEncryptionEvent() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Use enum when converting to TS
|
||||||
|
export const HistoryVisibility = Object.freeze({
|
||||||
|
Joined: "joined",
|
||||||
|
Invited: "invited",
|
||||||
|
WorldReadable: "world_readable",
|
||||||
|
Shared: "shared",
|
||||||
|
});
|
||||||
|
|
||||||
|
export function shouldShareKey(membership, historyVisibility) {
|
||||||
|
switch (historyVisibility) {
|
||||||
|
case HistoryVisibility.WorldReadable:
|
||||||
|
return true;
|
||||||
|
case HistoryVisibility.Shared:
|
||||||
|
// was part of room at some time
|
||||||
|
return membership !== undefined;
|
||||||
|
case HistoryVisibility.Joined:
|
||||||
|
return membership === "join";
|
||||||
|
case HistoryVisibility.Invited:
|
||||||
|
return membership === "invite" || membership === "join";
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user