diff options
Diffstat (limited to 'src')
23 files changed, 190 insertions, 148 deletions
diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 5b9e5c96..08c00c64 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -72,6 +72,7 @@ const afterStoreSetup = ({ store, i18n }) => { var scopeCopy = (config.scopeCopy) var subjectLineBehavior = (config.subjectLineBehavior) var alwaysShowSubjectInput = (config.alwaysShowSubjectInput) + var noAttachmentLinks = (config.noAttachmentLinks) store.dispatch('setInstanceOption', { name: 'theme', value: theme }) store.dispatch('setInstanceOption', { name: 'background', value: background }) @@ -90,6 +91,8 @@ const afterStoreSetup = ({ store, i18n }) => { store.dispatch('setInstanceOption', { name: 'scopeCopy', value: scopeCopy }) store.dispatch('setInstanceOption', { name: 'subjectLineBehavior', value: subjectLineBehavior }) store.dispatch('setInstanceOption', { name: 'alwaysShowSubjectInput', value: alwaysShowSubjectInput }) + store.dispatch('setInstanceOption', { name: 'noAttachmentLinks', value: noAttachmentLinks }) + if (chatDisabled) { store.dispatch('disableChat') } @@ -165,6 +168,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/boot/routes.js b/src/boot/routes.js index 8ea8cc7f..d349ec45 100644 --- a/src/boot/routes.js +++ b/src/boot/routes.js @@ -20,48 +20,24 @@ export default (store) => { redirect: _to => { return (store.state.users.currentUser ? store.state.instance.redirectRootLogin - : store.state.instance.redirectRootNoLogin) || '/~/main/all' + : store.state.instance.redirectRootNoLogin) || '/main/all' } }, - { name: 'public-external-timeline', path: '/~/main/all', component: PublicAndExternalTimeline }, - { name: 'public-timeline', path: '/~/main/public', component: PublicTimeline }, - { name: 'friends', path: '/~/main/friends', component: FriendsTimeline }, - // Beginning of temporary redirects - { path: '/main/:route', - redirect: to => { - const { params } = to - const route = params.route ? params.route : 'all' - - return { path: `/~/main/${route}` } - } - }, - { path: '/tag/:tag', - redirect: to => { - const { params } = to - - return { path: `/~/tag/${params.tag}` } - } - }, - { path: '/notice/:id', - redirect: to => { - const { params } = to - - return { path: `/~/notice/${params.id}` } - } - }, - // End of temporary redirects - { name: 'tag-timeline', path: '/~/tag/:tag', component: TagTimeline }, - { name: 'conversation', path: '/~/notice/:id', component: ConversationPage, meta: { dontScroll: true } }, - { name: 'user-profile', path: '/:name', component: UserProfile }, - { name: 'external-user-profile', path: '/~/users/:id', component: UserProfile }, - { name: 'mentions', path: '/:username/mentions', component: Mentions }, - { name: 'dms', path: '/:username/dms', component: DMs }, - { name: 'settings', path: '/~/settings', component: Settings }, - { name: 'registration', path: '/~/registration', component: Registration }, - { name: 'registration', path: '/~/registration/:token', component: Registration }, - { name: 'friend-requests', path: '/~/friend-requests', component: FollowRequests }, - { name: 'user-settings', path: '/~/user-settings', component: UserSettings }, - { name: 'oauth-callback', path: '/~/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) }, - { name: 'user-search', path: '/~/user-search', component: UserSearch, props: (route) => ({ query: route.query.query }) } + { name: 'public-external-timeline', path: '/main/all', component: PublicAndExternalTimeline }, + { name: 'public-timeline', path: '/main/public', component: PublicTimeline }, + { name: 'friends', path: '/main/friends', component: FriendsTimeline }, + { name: 'tag-timeline', path: '/tag/:tag', component: TagTimeline }, + { name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } }, + { name: 'external-user-profile', path: '/users/:id', component: UserProfile }, + { name: 'mentions', path: '/users/:username/mentions', component: Mentions }, + { name: 'dms', path: '/users/:username/dms', component: DMs }, + { name: 'settings', path: '/settings', component: Settings }, + { name: 'registration', path: '/registration', component: Registration }, + { name: 'registration', path: '/registration/:token', component: Registration }, + { name: 'friend-requests', path: '/friend-requests', component: FollowRequests }, + { name: 'user-settings', path: '/user-settings', component: UserSettings }, + { name: 'oauth-callback', path: '/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) }, + { name: 'user-search', path: '/user-search', component: UserSearch, props: (route) => ({ query: route.query.query }) }, + { name: 'user-profile', path: '/(users/)?:name', component: UserProfile } ] } diff --git a/src/components/chat_panel/chat_panel.js b/src/components/chat_panel/chat_panel.js index e175e90c..8db12abb 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/login_form/login_form.js b/src/components/login_form/login_form.js index 81426b44..013222a8 100644 --- a/src/components/login_form/login_form.js +++ b/src/components/login_form/login_form.js @@ -32,7 +32,7 @@ const LoginForm = { .then((result) => { this.$store.commit('setToken', result.access_token) this.$store.dispatch('loginUser', result.access_token) - this.$router.push('/~/main/friends') + this.$router.push({name: 'friends'}) }) }) } diff --git a/src/components/notification/notification.js b/src/components/notification/notification.js index 9ab870b6..e83b2263 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/oauth_callback/oauth_callback.js b/src/components/oauth_callback/oauth_callback.js index 18e24159..e3d45ee1 100644 --- a/src/components/oauth_callback/oauth_callback.js +++ b/src/components/oauth_callback/oauth_callback.js @@ -11,7 +11,7 @@ const oac = { }).then((result) => { this.$store.commit('setToken', result.access_token) this.$store.dispatch('loginUser', result.access_token) - this.$router.push('/~/main/friends') + this.$router.push({name: 'friends'}) }) } } diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js index dd8e6e5d..ab6cd64d 100644 --- a/src/components/registration/registration.js +++ b/src/components/registration/registration.js @@ -28,7 +28,7 @@ const registration = { }, created () { if ((!this.registrationOpen && !this.token) || this.signedIn) { - this.$router.push('/~/main/all') + this.$router.push({name: 'root'}) } this.setCaptcha() @@ -58,7 +58,7 @@ const registration = { if (!this.$v.$invalid) { try { await this.signUp(this.user) - this.$router.push('/~/main/friends') + this.$router.push({name: 'friends'}) } catch (error) { console.warn('Registration failed: ' + error) } diff --git a/src/components/status/status.js b/src/components/status/status.js index e683056f..d4eb0d60 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 f0fff335..615e6487 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 75185053..6d9b3c2f 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/user_card_content/user_card_content.vue b/src/components/user_card_content/user_card_content.vue index c5222519..c76c41a9 100644 --- a/src/components/user_card_content/user_card_content.vue +++ b/src/components/user_card_content/user_card_content.vue @@ -2,22 +2,25 @@ <div id="heading" class="profile-panel-background" :style="headingStyle"> <div class="panel-heading text-center"> <div class='user-info'> - <router-link @click.native="activatePanel && activatePanel('timeline')" :to="{ name: 'user-settings' }" style="float: right; margin-top:16px;" v-if="!isOtherUser"> - <i class="button-icon icon-cog usersettings" :title="$t('tool_tip.user_settings')"></i> - </router-link> - <a :href="user.statusnet_profile_url" target="_blank" class="floater" v-if="isOtherUser"> - <i class="icon-link-ext usersettings"></i> - </a> <div class='container'> <router-link @click.native="activatePanel && activatePanel('timeline')" :to="userProfileLink(user)"> <StillImage class="avatar" :class='{ "better-shadow": betterShadow }' :src="user.profile_image_url_original"/> </router-link> <div class="name-and-screen-name"> - <div :title="user.name" class='user-name' v-if="user.name_html" v-html="user.name_html"></div> - <div :title="user.name" class='user-name' v-else>{{user.name}}</div> + <div class="top-line"> + <div :title="user.name" class='user-name' v-if="user.name_html" v-html="user.name_html"></div> + <div :title="user.name" class='user-name' v-else>{{user.name}}</div> + <router-link @click.native="activatePanel && activatePanel('timeline')" :to="{ name: 'user-settings' }" v-if="!isOtherUser"> + <i class="button-icon icon-cog usersettings" :title="$t('tool_tip.user_settings')"></i> + </router-link> + <a :href="user.statusnet_profile_url" target="_blank" v-if="isOtherUser"> + <i class="icon-link-ext usersettings"></i> + </a> + </div> + <router-link @click.native="activatePanel && activatePanel('timeline')" class='user-screen-name' :to="userProfileLink(user)"> - <span>@{{user.screen_name}}</span><span v-if="user.locked"><i class="icon icon-lock"></i></span> - <span v-if="!hideUserStatsLocal" class="dailyAvg">{{dailyAvg}} {{ $t('user_card.per_day') }}</span> + <span class="handle">@{{user.screen_name}}</span><span v-if="user.locked"><i class="icon icon-lock"></i></span> + <span v-if="!hideUserStatsLocal && !hideBio" class="dailyAvg">{{dailyAvg}} {{ $t('user_card.per_day') }}</span> </router-link> </div> </div> @@ -25,7 +28,7 @@ <div v-if="user.follows_you && loggedIn && isOtherUser" class="following"> {{ $t('user_card.follows_you') }} </div> - <div class="floater" v-if="isOtherUser && (loggedIn || !switcher)"> + <div class="highlighter" v-if="isOtherUser && (loggedIn || !switcher)"> <!-- id's need to be unique, otherwise vue confuses which user-card checkbox belongs to --> <input class="userHighlightText" type="text" :id="'userHighlightColorTx'+user.id" v-if="userHighlightType !== 'disabled'" v-model="userHighlightColor"/> <input class="userHighlightCl" type="color" :id="'userHighlightColor'+user.id" v-if="userHighlightType !== 'disabled'" v-model="userHighlightColor"/> @@ -139,7 +142,7 @@ border-bottom-right-radius: 0; .panel-heading { - padding: 0.6em 0em; + padding: .6em 0; text-align: center; box-shadow: none; } @@ -158,10 +161,10 @@ .user-info { color: $fallback--lightText; color: var(--lightText, $fallback--lightText); - padding: 0 16px; + padding: 0 26px; .container { - padding: 16px 10px 6px 10px; + padding: 16px 0 6px; display: flex; max-height: 56px; @@ -218,11 +221,15 @@ vertical-align: middle; object-fit: contain } + .top-line { + display: flex; + } } .user-name{ text-overflow: ellipsis; overflow: hidden; + flex: 1 0 auto; } .user-screen-name { @@ -232,27 +239,73 @@ font-weight: light; font-size: 15px; padding-right: 0.1em; + width: 100%; + display: flex; + + .dailyAvg { + min-width: 1px; + flex: 0 0 auto; + } + + .handle { + min-width: 1px; + flex: 0 1 auto; + text-overflow: ellipsis; + overflow: hidden; + } } .user-meta { - margin-bottom: .4em; + margin-bottom: .15em; + display: flex; + align-items: baseline; + font-size: 14px; + line-height: 22px; + flex-wrap: wrap; .following { - font-size: 14px; - flex: 0 0 100%; + flex: 1 0 auto; margin: 0; - padding-left: 16px; + margin-bottom: .25em; text-align: left; - float: left; - } - .floater { - margin: 0; } - &::after { - display: block; - content: ''; - clear: both; + .highlighter { + flex: 0 1 auto; + display: flex; + flex-wrap: wrap; + margin-right: -.5em; + align-self: start; + + .userHighlightCl { + padding: 2px 10px; + flex: 1 0 auto; + } + + .userHighlightSel, + .userHighlightSel.select { + padding-top: 0; + padding-bottom: 0; + flex: 1 0 auto; + } + .userHighlightSel.select i { + line-height: 22px; + } + + .userHighlightText { + width: 70px; + flex: 1 0 auto; + } + + .userHighlightCl, + .userHighlightText, + .userHighlightSel, + .userHighlightSel.select { + height: 22px; + vertical-align: top; + margin-right: .5em; + margin-bottom: .25em; + } } } .user-interactions { @@ -260,8 +313,13 @@ flex-flow: row wrap; justify-content: space-between; + margin-right: -.75em; + div { - flex: 1; + flex: 1 0 0; + margin-right: .75em; + margin-bottom: .6em; + white-space: nowrap; } .mute { @@ -280,8 +338,9 @@ } button { - width: 92%; + width: 100%; height: 100%; + margin: 0; } .remote-button { @@ -304,10 +363,11 @@ justify-content: space-between; color: $fallback--lightText; color: var(--lightText, $fallback--lightText); + flex-wrap: wrap; } .user-count { - flex: 1; + flex: 1 0 auto; padding: .5em 0 .5em 0; margin: 0 .5em; @@ -327,32 +387,5 @@ color: #CCC; } .floater { - float: right; - margin-top: 16px; - - .userHighlightCl { - padding: 2px 10px; - } - .userHighlightSel, - .userHighlightSel.select { - padding-top: 0; - padding-bottom: 0; - } - .userHighlightSel.select i { - line-height: 22px; - } - - .userHighlightText { - width: 70px; - } - - .userHighlightCl, - .userHighlightText, - .userHighlightSel, - .userHighlightSel.select { - height: 22px; - vertical-align: top; - margin-right: 0 - } } </style> diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index d5fac17d..dcce275a 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -257,7 +257,7 @@ const UserSettings = { .then((res) => { if (res.status === 'success') { this.$store.dispatch('logout') - this.$router.push('/~/main/all') + this.$router.push({name: 'root'}) } else { this.deleteAccountError = res.error } 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 b2183e6d..eaeb527a 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/lib/push_notifications_plugin.js b/src/lib/push_notifications_plugin.js new file mode 100644 index 00000000..f75bb823 --- /dev/null +++ b/src/lib/push_notifications_plugin.js @@ -0,0 +1,22 @@ +export default (store) => { + store.subscribe((mutation, state) => { + const vapidPublicKey = state.instance.vapidPublicKey + const webPushNotification = state.config.webPushNotifications + const permission = state.interface.notificationPermission === 'granted' + const user = state.users.currentUser + + const isUserMutation = mutation.type === 'setCurrentUser' + const isVapidMutation = mutation.type === 'setInstanceOption' && mutation.payload.name === 'vapidPublicKey' + const isPermMutation = mutation.type === 'setNotificationPermission' && mutation.payload === 'granted' + const isUserConfigMutation = mutation.type === 'setOption' && mutation.payload.name === 'webPushNotifications' + const isVisibilityMutation = mutation.type === 'setOption' && mutation.payload.name === 'notificationVisibility' + + if (isUserMutation || isVapidMutation || isPermMutation || isUserConfigMutation || isVisibilityMutation) { + if (user && vapidPublicKey && permission && webPushNotification) { + return store.dispatch('registerPushNotifications') + } else if (isUserConfigMutation && !webPushNotification) { + return store.dispatch('unregisterPushNotifications') + } + } + }) +} diff --git a/src/main.js b/src/main.js index c22a762e..f87ef9da 100644 --- a/src/main.js +++ b/src/main.js @@ -15,6 +15,7 @@ import VueTimeago from 'vue-timeago' import VueI18n from 'vue-i18n' import createPersistedState from './lib/persisted_state.js' +import pushNotifications from './lib/push_notifications_plugin.js' import messages from './i18n/messages.js' @@ -51,28 +52,6 @@ const persistedStateOptions = { ] } -const registerPushNotifications = store => { - store.subscribe((mutation, state) => { - const vapidPublicKey = state.instance.vapidPublicKey - const webPushNotification = state.config.webPushNotifications - const permission = state.interface.notificationPermission === 'granted' - const user = state.users.currentUser - - const isUserMutation = mutation.type === 'setCurrentUser' - const isVapidMutation = mutation.type === 'setInstanceOption' && mutation.payload.name === 'vapidPublicKey' - const isPermMutation = mutation.type === 'setNotificationPermission' && mutation.payload === 'granted' - const isUserConfigMutation = mutation.type === 'setOption' && mutation.payload.name === 'webPushNotifications' - - if (isUserMutation || isVapidMutation || isPermMutation || isUserConfigMutation) { - if (user && vapidPublicKey && permission && webPushNotification) { - return store.dispatch('registerPushNotifications') - } else if (isUserConfigMutation && !webPushNotification) { - return store.dispatch('unregisterPushNotifications') - } - } - }) -} - createPersistedState(persistedStateOptions).then((persistedState) => { const store = new Vuex.Store({ modules: { @@ -85,7 +64,7 @@ createPersistedState(persistedStateOptions).then((persistedState) => { chat: chatModule, oauth: oauthModule }, - plugins: [persistedState, registerPushNotifications], + plugins: [persistedState, pushNotifications], strict: false // Socket modifies itself, let's ignore this for now. // strict: process.env.NODE_ENV !== 'production' }) diff --git a/src/modules/instance.js b/src/modules/instance.js index 342bc9ac..4ad41873 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -12,8 +12,8 @@ const defaultState = { logo: '/static/logo.png', logoMask: true, logoMargin: '.2em', - redirectRootNoLogin: '/~/main/all', - redirectRootLogin: '/~/main/friends', + redirectRootNoLogin: '/main/all', + redirectRootLogin: '/main/friends', showInstanceSpecificPanel: false, scopeOptionsEnabled: true, formattingOptionsEnabled: false, @@ -27,11 +27,13 @@ const defaultState = { loginMethod: 'password', nsfwCensorImage: undefined, vapidPublicKey: undefined, + noAttachmentLinks: false, // Nasty stuff pleromaBackend: true, emoji: [], customEmoji: [], + restrictedNicknames: [], // Feature-set, apparently, not everything here is reported... mediaProxyAvailable: false, diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 8c2d36bc..dccccf72 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -27,6 +27,7 @@ export const defaultState = { maxId: 0, minId: Number.POSITIVE_INFINITY, data: [], + idStore: {}, error: false }, favorites: new Set(), @@ -307,6 +308,7 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot } state.notifications.data.push(result) + state.notifications.idStore[notification.id] = result if ('Notification' in window && window.Notification.permission === 'granted') { const title = action.user.name diff --git a/src/modules/users.js b/src/modules/users.js index f2b59aaa..2f05ed3f 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -66,6 +66,9 @@ export const mutations = { setUserForStatus (state, status) { status.user = state.usersObject[status.user.id] }, + setUserForNotification (state, notification) { + notification.action.user = state.usersObject[notification.action.user.id] + }, setColor (state, { user: { id }, highlighted }) { const user = state.usersObject[id] set(user, 'highlight', highlighted) @@ -113,8 +116,9 @@ const users = { const token = store.state.currentUser.credentials const vapidPublicKey = store.rootState.instance.vapidPublicKey const isEnabled = store.rootState.config.webPushNotifications + const notificationVisibility = store.rootState.config.notificationVisibility - registerPushNotifications(isEnabled, vapidPublicKey, token) + registerPushNotifications(isEnabled, vapidPublicKey, token, notificationVisibility) }, unregisterPushNotifications (store) { const token = store.state.currentUser.credentials @@ -136,6 +140,21 @@ const users = { store.commit('setUserForStatus', status) }) }, + addNewNotifications (store, { notifications }) { + const users = compact(map(notifications, 'from_profile')) + const notificationIds = compact(notifications.map(_ => String(_.id))) + store.commit('addNewUsers', users) + + const notificationsObject = store.rootState.statuses.notifications.idStore + const relevantNotifications = Object.entries(notificationsObject) + .filter(([k, val]) => notificationIds.includes(k)) + .map(([k, val]) => val) + + // Reconnect users to notifications + each(relevantNotifications, (notification) => { + store.commit('setUserForNotification', notification) + }) + }, async signUp (store, userInfo) { store.commit('signUpPending') diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 182f9126..4ee95bd1 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -370,12 +370,13 @@ const unretweet = ({ id, credentials }) => { }) } -const postStatus = ({credentials, status, spoilerText, visibility, sensitive, mediaIds, inReplyToStatusId, contentType}) => { +const postStatus = ({credentials, status, spoilerText, visibility, sensitive, mediaIds, inReplyToStatusId, contentType, noAttachmentLinks}) => { const idsText = mediaIds.join(',') const form = new FormData() form.append('status', status) form.append('source', 'Pleroma FE') + if (noAttachmentLinks) form.append('no_attachment_links', noAttachmentLinks) if (spoilerText) form.append('spoiler_text', spoilerText) if (visibility) form.append('visibility', visibility) if (sensitive) form.append('sensitive', sensitive) diff --git a/src/services/new_api/oauth.js b/src/services/new_api/oauth.js index 97dec94f..9e656507 100644 --- a/src/services/new_api/oauth.js +++ b/src/services/new_api/oauth.js @@ -5,7 +5,7 @@ const getOrCreateApp = ({oauth, instance}) => { const form = new window.FormData() form.append('client_name', `PleromaFE_${Math.random()}`) - form.append('redirect_uris', `${window.location.origin}/~/oauth-callback`) + form.append('redirect_uris', `${window.location.origin}/oauth-callback`) form.append('scopes', 'read write follow') return window.fetch(url, { @@ -64,7 +64,7 @@ const getToken = ({app, instance, code}) => { form.append('client_secret', app.client_secret) form.append('grant_type', 'authorization_code') form.append('code', code) - form.append('redirect_uri', `${window.location.origin}/~/oauth-callback`) + form.append('redirect_uri', `${window.location.origin}/oauth-callback`) return window.fetch(url, { method: 'POST', diff --git a/src/services/push/push.js b/src/services/push/push.js index bf0c9680..1b189a29 100644 --- a/src/services/push/push.js +++ b/src/services/push/push.js @@ -51,7 +51,7 @@ function deleteSubscriptionFromBackEnd (token) { }) } -function sendSubscriptionToBackEnd (subscription, token) { +function sendSubscriptionToBackEnd (subscription, token, notificationVisibility) { return window.fetch('/api/v1/push/subscription/', { method: 'POST', headers: { @@ -62,10 +62,10 @@ function sendSubscriptionToBackEnd (subscription, token) { subscription, data: { alerts: { - follow: true, - favourite: true, - mention: true, - reblog: true + follow: notificationVisibility.follows, + favourite: notificationVisibility.likes, + mention: notificationVisibility.mentions, + reblog: notificationVisibility.repeats } } }) @@ -78,11 +78,11 @@ function sendSubscriptionToBackEnd (subscription, token) { }) } -export function registerPushNotifications (isEnabled, vapidPublicKey, token) { +export function registerPushNotifications (isEnabled, vapidPublicKey, token, notificationVisibility) { if (isPushSupported()) { getOrCreateServiceWorker() .then((registration) => subscribePush(registration, isEnabled, vapidPublicKey)) - .then((subscription) => sendSubscriptionToBackEnd(subscription, token)) + .then((subscription) => sendSubscriptionToBackEnd(subscription, token, notificationVisibility)) .catch((e) => console.warn(`Failed to setup Web Push Notifications: ${e.message}`)) } } diff --git a/src/services/status_poster/status_poster.service.js b/src/services/status_poster/status_poster.service.js index 7f8b0fc0..1e20d336 100644 --- a/src/services/status_poster/status_poster.service.js +++ b/src/services/status_poster/status_poster.service.js @@ -4,7 +4,7 @@ import apiService from '../api/api.service.js' const postStatus = ({ store, status, spoilerText, visibility, sensitive, media = [], inReplyToStatusId = undefined, contentType = 'text/plain' }) => { const mediaIds = map(media, 'id') - return apiService.postStatus({credentials: store.state.users.currentUser.credentials, status, spoilerText, visibility, sensitive, mediaIds, inReplyToStatusId, contentType}) + return apiService.postStatus({credentials: store.state.users.currentUser.credentials, status, spoilerText, visibility, sensitive, mediaIds, inReplyToStatusId, contentType, noAttachmentLinks: store.state.instance.noAttachmentLinks}) .then((data) => data.json()) .then((data) => { if (!data.error) { 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 3367eb8a..bca2c9cd 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 }) } } |
