From 621ac0bdc76ef1f38b227ede9200a947bbbc8073 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sat, 9 Nov 2019 19:49:50 -0600 Subject: [PATCH 01/14] docs: document FE interaction with the BE private setting --- docs/CONFIGURATION.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 35363537..f7397a55 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -96,3 +96,6 @@ Setting this will change the warning text that is displayed for direct messages. ATTENTION: If you actually want the behavior to change. You will need to set the appropriate option at the backend. See the backend documentation for information about that. DO NOT activate this without checking the backend configuration first! + +### Private Mode +If the `private` instance setting is enabled in the backend, features that are not accessible without authentication, such as the timelines and search will be disabled for unauthenticated users. From 99fd096ddd1cc657a86c41e7e96344b8bb1dc4de Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sat, 9 Nov 2019 19:53:03 -0600 Subject: [PATCH 02/14] boot: track whether private mode is enabled or not --- src/boot/after_store.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 226b67d8..cbe0c330 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -218,6 +218,9 @@ const getNodeInfo = async ({ store }) => { store.dispatch('setInstanceOption', { name: 'backendVersion', value: software.version }) store.dispatch('setInstanceOption', { name: 'pleromaBackend', value: software.name === 'pleroma' }) + const priv = metadata.private + store.dispatch('setInstanceOption', { name: 'private', value: priv }) + const frontendVersion = window.___pleromafe_commit_hash store.dispatch('setInstanceOption', { name: 'frontendVersion', value: frontendVersion }) store.dispatch('setInstanceOption', { name: 'tagPolicyAvailable', value: metadata.federation.mrf_policies.includes('TagPolicy') }) From 21f1637e437398ec56b6078cf28b58bd4a0299ba Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Mon, 11 Nov 2019 14:14:44 -0600 Subject: [PATCH 03/14] nav panel: refactor to use vuex mapState --- src/components/nav_panel/nav_panel.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js index aa3f7605..bfcab62e 100644 --- a/src/components/nav_panel/nav_panel.js +++ b/src/components/nav_panel/nav_panel.js @@ -1,4 +1,5 @@ import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service' +import { mapState } from 'vuex' const NavPanel = { created () { @@ -9,17 +10,11 @@ const NavPanel = { followRequestFetcher.startFetching({ store, credentials }) } }, - computed: { - currentUser () { - return this.$store.state.users.currentUser - }, - chat () { - return this.$store.state.chat.channel - }, - followRequestCount () { - return this.$store.state.api.followRequests.length - } - } + computed: mapState({ + currentUser: state => state.users.currentUser, + chat: state => state.chat.channel, + followRequestCount: state => state.api.followRequests.length + }) } export default NavPanel From 1f9674350cdf7455fe5540d377eb327edf1336ce Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Mon, 11 Nov 2019 14:18:36 -0600 Subject: [PATCH 04/14] nav panel: disable TWKN if federation disabled, disable Public and TWKN if privateMode is enabled --- src/components/nav_panel/nav_panel.js | 4 +++- src/components/nav_panel/nav_panel.vue | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js index bfcab62e..a6426d13 100644 --- a/src/components/nav_panel/nav_panel.js +++ b/src/components/nav_panel/nav_panel.js @@ -13,7 +13,9 @@ const NavPanel = { computed: mapState({ currentUser: state => state.users.currentUser, chat: state => state.chat.channel, - followRequestCount: state => state.api.followRequests.length + followRequestCount: state => state.api.followRequests.length, + privateMode: state => state.instance.private, + federating: state => state.instance.federationPolicy.federating || true }) } diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue index 28589bb1..d85c28bd 100644 --- a/src/components/nav_panel/nav_panel.vue +++ b/src/components/nav_panel/nav_panel.vue @@ -28,12 +28,12 @@ -
  • +
  • {{ $t("nav.public_tl") }}
  • -
  • +
  • {{ $t("nav.twkn") }} From cb5f73148a2dc9341d16326ed606d74e818fb61d Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Mon, 11 Nov 2019 14:25:38 -0600 Subject: [PATCH 05/14] app: search API is not available in private mode so disable it --- src/App.js | 3 ++- src/App.vue | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/App.js b/src/App.js index 04a40e30..e2b0e6db 100644 --- a/src/App.js +++ b/src/App.js @@ -97,7 +97,8 @@ export default { this.$store.state.instance.instanceSpecificPanelContent }, showFeaturesPanel () { return this.$store.state.instance.showFeaturesPanel }, - isMobileLayout () { return this.$store.state.interface.mobileLayout } + isMobileLayout () { return this.$store.state.interface.mobileLayout }, + privateMode () { return this.$store.state.instance.private } }, methods: { scrollToTop () { diff --git a/src/App.vue b/src/App.vue index dbe842ec..1f244b56 100644 --- a/src/App.vue +++ b/src/App.vue @@ -43,6 +43,7 @@ class="nav-icon mobile-hidden" @toggled="onSearchBarToggled" @click.stop.native + v-if="currentUser || !privateMode" /> Date: Mon, 11 Nov 2019 14:37:14 -0600 Subject: [PATCH 06/14] side drawer: same treatment --- src/components/side_drawer/side_drawer.js | 6 ++++++ src/components/side_drawer/side_drawer.vue | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js index 567d2e5e..2725d43a 100644 --- a/src/components/side_drawer/side_drawer.js +++ b/src/components/side_drawer/side_drawer.js @@ -34,6 +34,12 @@ const SideDrawer = { }, followRequestCount () { return this.$store.state.api.followRequests.length + }, + privateMode () { + return this.$store.state.instance.private + }, + federating () { + return this.$store.state.instance.federationPolicy.federating || true } }, methods: { diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index 214b8e0c..be18a5d7 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -79,12 +79,12 @@
  • -
  • +
  • {{ $t("nav.public_tl") }}
  • -
  • +
  • {{ $t("nav.twkn") }} @@ -99,7 +99,7 @@
    • -
    • +
    • {{ $t("nav.search") }} From 3eeb3dc57296cba13e3760a79b635fba5a332be0 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 12 Dec 2019 13:37:32 -0600 Subject: [PATCH 07/14] Lint --- src/App.vue | 2 +- src/components/nav_panel/nav_panel.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/App.vue b/src/App.vue index d455e9ed..5f8517d4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -43,8 +43,8 @@ Date: Thu, 12 Dec 2019 13:39:18 -0600 Subject: [PATCH 08/14] More lint --- src/components/side_drawer/side_drawer.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index 1454e0d8..064472b9 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -79,12 +79,14 @@
    • -
    • +
    • {{ $t("nav.public_tl") }}
    • -
    • +
    • {{ $t("nav.twkn") }} @@ -99,7 +101,8 @@
      -
    • +
    • {{ $t("nav.search") }} From afe5b3a82d5b6e9b02fa6db9354060aa72edb712 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 12 Dec 2019 13:41:52 -0600 Subject: [PATCH 09/14] More lint --- src/components/side_drawer/side_drawer.vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index 064472b9..bf61d38c 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -79,14 +79,14 @@
    • -
    • +
    • {{ $t("nav.public_tl") }}
    • -
    • +
    • {{ $t("nav.twkn") }} @@ -101,8 +101,8 @@
      -
    • +
    • {{ $t("nav.search") }} From 7ddd5af0812a73d6a898331e38603067e0cd219b Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 12 Dec 2019 13:46:07 -0600 Subject: [PATCH 10/14] Finally trust eslint --- src/App.vue | 2 +- src/components/side_drawer/side_drawer.vue | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/App.vue b/src/App.vue index 5f8517d4..1b1c2648 100644 --- a/src/App.vue +++ b/src/App.vue @@ -41,9 +41,9 @@
    • -
    • +
    • {{ $t("nav.public_tl") }}
    • -
    • +
    • {{ $t("nav.twkn") }} @@ -101,8 +105,10 @@
      -
    • +
    • {{ $t("nav.search") }} From 2514dc183f604686d1648c0a69f6eba00d943ce7 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 12 Dec 2019 13:51:50 -0600 Subject: [PATCH 11/14] Logic should be to hide TWKN if not federating OR if instance is not public Private instances should not show any timelines --- src/components/nav_panel/nav_panel.vue | 2 +- src/components/side_drawer/side_drawer.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue index 97c36711..034259d9 100644 --- a/src/components/nav_panel/nav_panel.vue +++ b/src/components/nav_panel/nav_panel.vue @@ -33,7 +33,7 @@ {{ $t("nav.public_tl") }}
    • -
    • +
    • {{ $t("nav.twkn") }} diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index 49c25bba..3fba9058 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -88,7 +88,7 @@
    • From 0743fbb28b94dd4308f8e2ca01d9def91b6ffddf Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 12 Dec 2019 13:56:07 -0600 Subject: [PATCH 12/14] The value we are looking for is federationPolicy.enabled, not federationPolicy.federating Also the || true fallback does not work and always becomes true --- src/components/nav_panel/nav_panel.js | 2 +- src/components/side_drawer/side_drawer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js index f27727fc..7da9f8c6 100644 --- a/src/components/nav_panel/nav_panel.js +++ b/src/components/nav_panel/nav_panel.js @@ -11,7 +11,7 @@ const NavPanel = { chat: state => state.chat.channel, followRequestCount: state => state.api.followRequests.length, privateMode: state => state.instance.private, - federating: state => state.instance.federationPolicy.federating || true + federating: state => state.instance.federationPolicy.enabled }) } diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js index 22cb1a55..e08f7cbe 100644 --- a/src/components/side_drawer/side_drawer.js +++ b/src/components/side_drawer/side_drawer.js @@ -46,7 +46,7 @@ const SideDrawer = { return this.$store.state.instance.private }, federating () { - return this.$store.state.instance.federationPolicy.federating || true + return this.$store.state.instance.federationPolicy.enabled } }, methods: { From 8d14036a23adbd13b098abeeef9622471f4a64d3 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 12 Dec 2019 15:17:23 -0600 Subject: [PATCH 13/14] Add fallback in case BE does not report federating status in nodeinfo --- src/components/nav_panel/nav_panel.js | 2 +- src/components/side_drawer/side_drawer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js index 7da9f8c6..515e47e6 100644 --- a/src/components/nav_panel/nav_panel.js +++ b/src/components/nav_panel/nav_panel.js @@ -11,7 +11,7 @@ const NavPanel = { chat: state => state.chat.channel, followRequestCount: state => state.api.followRequests.length, privateMode: state => state.instance.private, - federating: state => state.instance.federationPolicy.enabled + federating: state => state.instance.federationPolicy.enabled || state.instance.federationPolicy.enabled !== false }) } diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js index e08f7cbe..670d28b4 100644 --- a/src/components/side_drawer/side_drawer.js +++ b/src/components/side_drawer/side_drawer.js @@ -46,7 +46,7 @@ const SideDrawer = { return this.$store.state.instance.private }, federating () { - return this.$store.state.instance.federationPolicy.enabled + return this.$store.state.instance.federationPolicy.enabled || this.$store.state.instance.federationPolicy.enabled !== false } }, methods: { From d899d06973c7c46e77f9e47f480d6967e83b4adf Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 12 Dec 2019 15:29:50 -0600 Subject: [PATCH 14/14] Use a centralized fallback for missing values and use instance.federating instead of instance.federation.enabled --- src/boot/after_store.js | 6 ++++++ src/components/nav_panel/nav_panel.js | 2 +- src/components/side_drawer/side_drawer.js | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/boot/after_store.js b/src/boot/after_store.js index f169d7ba..228a0497 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -228,6 +228,12 @@ const getNodeInfo = async ({ store }) => { const federation = metadata.federation store.dispatch('setInstanceOption', { name: 'federationPolicy', value: federation }) + store.dispatch('setInstanceOption', { + name: 'federating', + value: typeof federation.enabled === 'undefined' + ? true + : federation.enabled + }) const accounts = metadata.staffAccounts await resolveStaffAccounts({ store, accounts }) diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js index 515e47e6..d9268585 100644 --- a/src/components/nav_panel/nav_panel.js +++ b/src/components/nav_panel/nav_panel.js @@ -11,7 +11,7 @@ const NavPanel = { chat: state => state.chat.channel, followRequestCount: state => state.api.followRequests.length, privateMode: state => state.instance.private, - federating: state => state.instance.federationPolicy.enabled || state.instance.federationPolicy.enabled !== false + federating: state => state.instance.federating }) } diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js index 670d28b4..2534eb8f 100644 --- a/src/components/side_drawer/side_drawer.js +++ b/src/components/side_drawer/side_drawer.js @@ -46,7 +46,7 @@ const SideDrawer = { return this.$store.state.instance.private }, federating () { - return this.$store.state.instance.federationPolicy.enabled || this.$store.state.instance.federationPolicy.enabled !== false + return this.$store.state.instance.federating } }, methods: {