Merge branch 'feature/redirect-external-user-to-id' into 'develop'
[Feature] Redirect remote user to internal ID See merge request pleroma/pleroma-fe!921
This commit is contained in:
commit
044c9ad056
4 changed files with 67 additions and 0 deletions
|
@ -18,6 +18,7 @@ import AuthForm from 'components/auth_form/auth_form.js'
|
||||||
import ChatPanel from 'components/chat_panel/chat_panel.vue'
|
import ChatPanel from 'components/chat_panel/chat_panel.vue'
|
||||||
import WhoToFollow from 'components/who_to_follow/who_to_follow.vue'
|
import WhoToFollow from 'components/who_to_follow/who_to_follow.vue'
|
||||||
import About from 'components/about/about.vue'
|
import About from 'components/about/about.vue'
|
||||||
|
import RemoteUserResolver from 'components/remote_user_resolver/remote_user_resolver.vue'
|
||||||
|
|
||||||
export default (store) => {
|
export default (store) => {
|
||||||
const validateAuthenticatedRoute = (to, from, next) => {
|
const validateAuthenticatedRoute = (to, from, next) => {
|
||||||
|
@ -42,6 +43,16 @@ export default (store) => {
|
||||||
{ name: 'friends', path: '/main/friends', component: FriendsTimeline, beforeEnter: validateAuthenticatedRoute },
|
{ name: 'friends', path: '/main/friends', component: FriendsTimeline, beforeEnter: validateAuthenticatedRoute },
|
||||||
{ name: 'tag-timeline', path: '/tag/:tag', component: TagTimeline },
|
{ name: 'tag-timeline', path: '/tag/:tag', component: TagTimeline },
|
||||||
{ name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } },
|
{ name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } },
|
||||||
|
{ name: 'remote-user-profile-acct',
|
||||||
|
path: '/remote-users/(@?):username([^/@]+)@:hostname([^/@]+)',
|
||||||
|
component: RemoteUserResolver,
|
||||||
|
beforeEnter: validateAuthenticatedRoute
|
||||||
|
},
|
||||||
|
{ name: 'remote-user-profile',
|
||||||
|
path: '/remote-users/:hostname/:username',
|
||||||
|
component: RemoteUserResolver,
|
||||||
|
beforeEnter: validateAuthenticatedRoute
|
||||||
|
},
|
||||||
{ name: 'external-user-profile', path: '/users/:id', component: UserProfile },
|
{ name: 'external-user-profile', path: '/users/:id', component: UserProfile },
|
||||||
{ name: 'interactions', path: '/users/:username/interactions', component: Interactions, beforeEnter: validateAuthenticatedRoute },
|
{ name: 'interactions', path: '/users/:username/interactions', component: Interactions, beforeEnter: validateAuthenticatedRoute },
|
||||||
{ name: 'dms', path: '/users/:username/dms', component: DMs, beforeEnter: validateAuthenticatedRoute },
|
{ name: 'dms', path: '/users/:username/dms', component: DMs, beforeEnter: validateAuthenticatedRoute },
|
||||||
|
|
31
src/components/remote_user_resolver/remote_user_resolver.js
Normal file
31
src/components/remote_user_resolver/remote_user_resolver.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
const RemoteUserResolver = {
|
||||||
|
data: () => ({
|
||||||
|
error: false
|
||||||
|
}),
|
||||||
|
mounted () {
|
||||||
|
this.redirect()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
redirect () {
|
||||||
|
const acct = this.$route.params.username + '@' + this.$route.params.hostname
|
||||||
|
this.$store.state.api.backendInteractor.fetchUser({ id: acct })
|
||||||
|
.then((externalUser) => {
|
||||||
|
if (externalUser.error) {
|
||||||
|
this.error = true
|
||||||
|
} else {
|
||||||
|
this.$store.commit('addNewUsers', [externalUser])
|
||||||
|
const id = externalUser.id
|
||||||
|
this.$router.replace({
|
||||||
|
name: 'external-user-profile',
|
||||||
|
params: { id }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.error = true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default RemoteUserResolver
|
20
src/components/remote_user_resolver/remote_user_resolver.vue
Normal file
20
src/components/remote_user_resolver/remote_user_resolver.vue
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<template>
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
{{ $t('remote_user_resolver.remote_user_resolver') }}
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<p>
|
||||||
|
{{ $t('remote_user_resolver.searching_for') }} @{{ $route.params.username }}@{{ $route.params.hostname }}
|
||||||
|
</p>
|
||||||
|
<p v-if="error">
|
||||||
|
{{ $t('remote_user_resolver.error') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./remote_user_resolver.js"></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
</style>
|
|
@ -172,6 +172,11 @@
|
||||||
"password_confirmation_match": "should be the same as password"
|
"password_confirmation_match": "should be the same as password"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"remote_user_resolver": {
|
||||||
|
"remote_user_resolver": "Remote user resolver",
|
||||||
|
"searching_for": "Searching for",
|
||||||
|
"error": "Not found."
|
||||||
|
},
|
||||||
"selectable_list": {
|
"selectable_list": {
|
||||||
"select_all": "Select all"
|
"select_all": "Select all"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue