Treat reserved users like external users in the frontend.

This commit is contained in:
Lambda 2018-12-26 14:50:48 +01:00
parent 24eba26c5b
commit f35dbaf064
10 changed files with 21 additions and 9 deletions

View file

@ -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 })

View file

@ -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)
}
}
}

View file

@ -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: {

View file

@ -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: {

View file

@ -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)
}
}
}

View file

@ -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)
}
}
}

View file

@ -62,7 +62,7 @@ const WhoToFollowPanel = {
},
methods: {
userProfileLink (id, name) {
return generateProfileLink(id, name)
return generateProfileLink(id, name, this.$store.state.instance.restrictedNicknames)
}
},
watch: {

View file

@ -32,6 +32,7 @@ const defaultState = {
pleromaBackend: true,
emoji: [],
customEmoji: [],
restrictedNicknames: [],
// Feature-set, apparently, not everything here is reported...
mediaProxyAvailable: false,

View file

@ -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 })
}
}

View file

@ -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 }
})
})
})