diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 5b9e5c960b..e716082a98 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -165,6 +165,8 @@ const afterStoreSetup = ({ store, i18n }) => { store.dispatch('setInstanceOption', { name: 'chatAvailable', value: features.includes('chat') }) store.dispatch('setInstanceOption', { name: 'gopherAvailable', value: features.includes('gopher') }) + store.dispatch('setInstanceOption', { name: 'restrictedNicknames', value: metadata.restrictedNicknames }) + const suggestions = metadata.suggestions store.dispatch('setInstanceOption', { name: 'suggestionsEnabled', value: suggestions.enabled }) store.dispatch('setInstanceOption', { name: 'suggestionsWeb', value: suggestions.web }) diff --git a/src/components/chat_panel/chat_panel.js b/src/components/chat_panel/chat_panel.js index e175e90c98..8db12abb35 100644 --- a/src/components/chat_panel/chat_panel.js +++ b/src/components/chat_panel/chat_panel.js @@ -22,7 +22,7 @@ const chatPanel = { this.collapsed = !this.collapsed }, userProfileLink (user) { - return generateProfileLink(user.id, user.screen_name) + return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames) } } } diff --git a/src/components/notification/notification.js b/src/components/notification/notification.js index 9ab870b643..e83b226324 100644 --- a/src/components/notification/notification.js +++ b/src/components/notification/notification.js @@ -23,7 +23,7 @@ const Notification = { this.userExpanded = !this.userExpanded }, userProfileLink (user) { - return generateProfileLink(user.id, user.screen_name) + return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames) } }, computed: { diff --git a/src/components/status/status.js b/src/components/status/status.js index e683056f99..d4eb0d604e 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -291,7 +291,7 @@ const Status = { this.showPreview = false }, userProfileLink (id, name) { - return generateProfileLink(id, name) + return generateProfileLink(id, name, this.$store.state.instance.restrictedNicknames) } }, watch: { diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index f0fff3359b..615e64879c 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -33,7 +33,7 @@ const UserCard = { this.$store.dispatch('removeFollowRequest', this.user) }, userProfileLink (user) { - return generateProfileLink(user.id, user.screen_name) + return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames) } } } diff --git a/src/components/user_card_content/user_card_content.js b/src/components/user_card_content/user_card_content.js index 751850539b..6d9b3c2fbe 100644 --- a/src/components/user_card_content/user_card_content.js +++ b/src/components/user_card_content/user_card_content.js @@ -180,7 +180,7 @@ export default { } }, userProfileLink (user) { - return generateProfileLink(user.id, user.screen_name) + return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames) } } } diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.js b/src/components/who_to_follow_panel/who_to_follow_panel.js index b2183e6d8c..eaeb527ab6 100644 --- a/src/components/who_to_follow_panel/who_to_follow_panel.js +++ b/src/components/who_to_follow_panel/who_to_follow_panel.js @@ -62,7 +62,7 @@ const WhoToFollowPanel = { }, methods: { userProfileLink (id, name) { - return generateProfileLink(id, name) + return generateProfileLink(id, name, this.$store.state.instance.restrictedNicknames) } }, watch: { diff --git a/src/modules/instance.js b/src/modules/instance.js index ab88306f32..093bfd0f8d 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -32,6 +32,7 @@ const defaultState = { pleromaBackend: true, emoji: [], customEmoji: [], + restrictedNicknames: [], // Feature-set, apparently, not everything here is reported... mediaProxyAvailable: false, diff --git a/src/services/user_profile_link_generator/user_profile_link_generator.js b/src/services/user_profile_link_generator/user_profile_link_generator.js index 3367eb8a2c..bca2c9cdc0 100644 --- a/src/services/user_profile_link_generator/user_profile_link_generator.js +++ b/src/services/user_profile_link_generator/user_profile_link_generator.js @@ -1,7 +1,10 @@ -const generateProfileLink = (id, screenName) => { +import { includes } from 'lodash' + +const generateProfileLink = (id, screenName, restrictedNicknames) => { + const complicated = (isExternal(screenName) || includes(restrictedNicknames, screenName)) return { - name: (isExternal(screenName) ? 'external-user-profile' : 'user-profile'), - params: (isExternal(screenName) ? { id } : { name: screenName }) + name: (complicated ? 'external-user-profile' : 'user-profile'), + params: (complicated ? { id } : { name: screenName }) } } diff --git a/test/unit/specs/services/user_profile_link_generator/user_profile_link_generator.spec.js b/test/unit/specs/services/user_profile_link_generator/user_profile_link_generator.spec.js index 4366f7998f..8c7a28950e 100644 --- a/test/unit/specs/services/user_profile_link_generator/user_profile_link_generator.spec.js +++ b/test/unit/specs/services/user_profile_link_generator/user_profile_link_generator.spec.js @@ -12,4 +12,10 @@ describe('generateProfileLink', () => { name: 'external-user-profile', params: { id: 1 } }) }) + + it('returns obj for restricted user', () => { + expect(generateProfileLink(1, 'lain', ['lain'])).to.eql({ + name: 'external-user-profile', params: { id: 1 } + }) + }) })