Indicate who and when the room was set to `world_readable`

This commit is contained in:
Eric Eastwood 2023-06-28 20:09:09 -05:00
parent a79342f83c
commit d23b880e90
5 changed files with 39 additions and 3 deletions

View File

@ -210,9 +210,15 @@ const fetchRoomData = traceFunction(async function (
}
let historyVisibility;
let historyVisibilityEventMeta;
if (stateHistoryVisibilityResDataOutcome.reason === undefined) {
const { data } = stateHistoryVisibilityResDataOutcome.value;
historyVisibility = data?.content?.history_visibility;
historyVisibilityEventMeta = {
historyVisibility,
sender: data?.sender,
originServerTs: data?.origin_server_ts,
};
}
let roomCreationTs;
@ -240,6 +246,7 @@ const fetchRoomData = traceFunction(async function (
canonicalAlias,
avatarUrl,
historyVisibility,
historyVisibilityEventMeta,
roomCreationTs,
predecessorRoomId,
predecessorLastKnownEventId,

View File

@ -833,7 +833,10 @@ router.get(
if (!allowedToViewRoom) {
throw new StatusError(
403,
`Only \`world_readable\` rooms can be viewed in the archive. ${roomData.id} has m.room.history_visiblity=${roomData.historyVisibility}`
`Only \`world_readable\` rooms can be viewed in the archive. ` +
`${roomData.id} has m.room.history_visiblity=${roomData.historyVisibility} ` +
`(set by ${roomData.historyVisibilityEventMeta?.sender} on ` +
`${new Date(roomData.historyVisibilityEventMeta?.originServerTs).toISOString()})`
);
}

View File

@ -118,6 +118,7 @@ async function mountHydrogen() {
events,
stateEventMap,
shouldIndex,
historyVisibilityEventMeta: roomData.historyVisibilityEventMeta,
basePath: config.basePath,
});

View File

@ -75,6 +75,7 @@ class ArchiveRoomViewModel extends ViewModel {
events,
stateEventMap,
shouldIndex,
historyVisibilityEventMeta,
basePath,
} = options;
assert(homeserverUrl);
@ -85,6 +86,9 @@ class ArchiveRoomViewModel extends ViewModel {
assert(events);
assert(stateEventMap);
assert(shouldIndex !== undefined);
assert(historyVisibilityEventMeta.historyVisibility);
assert(historyVisibilityEventMeta.sender);
assert(historyVisibilityEventMeta.originServerTs);
assert(events);
this._room = room;
@ -213,6 +217,7 @@ class ArchiveRoomViewModel extends ViewModel {
shouldShowTimeSelector,
timeSelectorViewModel: this._timeSelectorViewModel,
shouldIndex,
historyVisibilityEventMeta,
get developerOptionsUrl() {
return urlRouter.urlForSegments([
navigation.segment('room', room.id),

View File

@ -10,12 +10,28 @@ class RightPanelContentView extends TemplateView {
render(t, vm) {
assert(vm.shouldIndex !== undefined);
assert(vm.shouldShowTimeSelector !== undefined);
assert(vm.historyVisibilityEventMeta.historyVisibility);
assert(vm.historyVisibilityEventMeta.sender);
assert(vm.historyVisibilityEventMeta.originServerTs);
let maybeIndexedMessage = 'This room is not being indexed by search engines ';
if (vm.shouldIndex) {
maybeIndexedMessage = 'This room is being indexed by search engines ';
maybeIndexedMessage = 'This room is being indexed by search engines';
}
const historyVisibilitySender = vm.historyVisibilityEventMeta.sender;
let historyVisibilityDisplayValue = vm.historyVisibilityEventMeta.historyVisibility;
if (vm.historyVisibilityEventMeta.historyVisibility === 'world_readable') {
historyVisibilityDisplayValue = 'world readable';
}
const [historyVisibilitySetDatePiece, _timePiece] = new Date(
vm.historyVisibilityEventMeta.originServerTs
)
.toISOString()
.split('T');
return t.div(
{
className: 'RightPanelContentView',
@ -33,9 +49,13 @@ class RightPanelContentView extends TemplateView {
className: 'RightPanelContentView_footer',
},
[
t.p([
`This room is accessible in the archive because it was set to ` +
`${historyVisibilityDisplayValue} by ${historyVisibilitySender} on ${historyVisibilitySetDatePiece}.`,
]),
t.p([
maybeIndexedMessage,
'(',
' (',
t.a(
{
className: 'external-link RightPanelContentView_footerLink',