From 390cdf4c5e1a5ec54d8017e02314715a8d4408a6 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 4 Sep 2021 14:47:11 -0500 Subject: [PATCH] Authenticated fetch: make the instance appear censored --- app/soapbox/reducers/instance.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/soapbox/reducers/instance.js b/app/soapbox/reducers/instance.js index 7d08b3713..f6a466d62 100644 --- a/app/soapbox/reducers/instance.js +++ b/app/soapbox/reducers/instance.js @@ -1,5 +1,6 @@ import { INSTANCE_FETCH_SUCCESS, + INSTANCE_FETCH_FAIL, NODEINFO_FETCH_SUCCESS, } from '../actions/instance'; import { PRELOAD_IMPORT } from 'soapbox/actions/preload'; @@ -71,12 +72,22 @@ const importConfigs = (state, configs) => { }); }; +const handleAuthFetch = state => { + // Authenticated fetch is enabled, so make the instance appear censored + return ImmutableMap({ + title: '██████', + description: '████████████', + }).merge(state); +}; + export default function instance(state = initialState, action) { switch(action.type) { case PRELOAD_IMPORT: return preloadImport(state, action, '/api/v1/instance'); case INSTANCE_FETCH_SUCCESS: return initialState.mergeDeep(fromJS(action.instance)); + case INSTANCE_FETCH_FAIL: + return action.error.response.status === 401 ? handleAuthFetch(state) : state; case NODEINFO_FETCH_SUCCESS: return nodeinfoToInstance(fromJS(action.nodeinfo)).mergeDeep(state); case ADMIN_CONFIG_UPDATE_REQUEST: