From ef6e2087aeff1cf76cd4e5a3f04685e228c169d4 Mon Sep 17 00:00:00 2001 From: Shpuld Shpludson Date: Tue, 5 Jan 2021 08:09:08 +0000 Subject: fix #1036 convert screen name to unicode with punycode --- .../entity_normalizer/entity_normalizer.service.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/services/entity_normalizer/entity_normalizer.service.js') diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index b1e68df5..206e6281 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -1,6 +1,7 @@ import escape from 'escape-html' import parseLinkHeader from 'parse-link-header' import { isStatusNotification } from '../notification_utils/notification_utils.js' +import punycode from 'punycode.js' /** NOTICE! ** * Do not initialize UI-generated data here. @@ -197,6 +198,19 @@ export const parseUser = (data) => { output.rights = output.rights || {} output.notification_settings = output.notification_settings || {} + // Convert punycode to unicode + if (output.screen_name.includes('@')) { + const parts = output.screen_name.split('@') + console.log(parts) + let unicodeDomain = punycode.toUnicode(parts[1]) + if (unicodeDomain !== parts[1]) { + // Add some identifier so users can potentially spot spoofing attempts: + // lain.com and xn--lin-6cd.com would appear identical otherwise. + unicodeDomain = '🌏' + unicodeDomain + output.screen_name = [parts[0], unicodeDomain].join('@') + } + } + return output } -- cgit v1.2.3-70-g09d2 From 65dbf7b85d680f0855e9f6706a4437d2f4a52227 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Tue, 12 Jan 2021 14:43:21 +0200 Subject: Add report button to status ellipsis menu --- CHANGELOG.md | 3 +++ src/components/account_actions/account_actions.js | 2 +- src/components/extra_buttons/extra_buttons.js | 9 +++++++-- src/components/extra_buttons/extra_buttons.vue | 10 ++++++++++ .../user_reporting_modal/user_reporting_modal.js | 2 +- src/modules/reports.js | 16 ++++++++++++---- .../entity_normalizer/entity_normalizer.service.js | 1 - 7 files changed, 34 insertions(+), 9 deletions(-) (limited to 'src/services/entity_normalizer/entity_normalizer.service.js') diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f270bfe..7164eb26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Added +- Added Report button to status ellipsis menu for easier reporting + ### Fixed - Follows/Followers tabs on user profiles now display the content properly. - Handle punycode in screen names diff --git a/src/components/account_actions/account_actions.js b/src/components/account_actions/account_actions.js index 395d6685..e53c4f77 100644 --- a/src/components/account_actions/account_actions.js +++ b/src/components/account_actions/account_actions.js @@ -35,7 +35,7 @@ const AccountActions = { this.$store.dispatch('unblockUser', this.user.id) }, reportUser () { - this.$store.dispatch('openUserReportingModal', this.user.id) + this.$store.dispatch('openUserReportingModal', { userId: this.user.id }) }, openChat () { this.$router.push({ diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js index b5b29e8a..dd45b6b9 100644 --- a/src/components/extra_buttons/extra_buttons.js +++ b/src/components/extra_buttons/extra_buttons.js @@ -9,7 +9,8 @@ import { faExternalLinkAlt } from '@fortawesome/free-solid-svg-icons' import { - faBookmark as faBookmarkReg + faBookmark as faBookmarkReg, + faFlag } from '@fortawesome/free-regular-svg-icons' library.add( @@ -19,7 +20,8 @@ library.add( faEyeSlash, faThumbtack, faShareAlt, - faExternalLinkAlt + faExternalLinkAlt, + faFlag ) const ExtraButtons = { @@ -66,6 +68,9 @@ const ExtraButtons = { this.$store.dispatch('unbookmark', { id: this.status.id }) .then(() => this.$emit('onSuccess')) .catch(err => this.$emit('onError', err.error.error)) + }, + reportStatus () { + this.$store.dispatch('openUserReportingModal', { userId: this.status.user.id, statusIds: [this.status.id] }) } }, computed: { diff --git a/src/components/extra_buttons/extra_buttons.vue b/src/components/extra_buttons/extra_buttons.vue index dc790cad..e845d8fc 100644 --- a/src/components/extra_buttons/extra_buttons.vue +++ b/src/components/extra_buttons/extra_buttons.vue @@ -109,6 +109,16 @@ icon="external-link-alt" />{{ $t("status.external_source") }} + status.user.id === userId) - commit('openUserReportingModal', { userId, statuses }) + openUserReportingModal ({ rootState, commit }, { userId, statusIds = [] }) { + const preTickedStatuses = statusIds.map(id => rootState.statuses.allStatusesObject[id]) + const preTickedIds = statusIds + const statuses = preTickedStatuses.concat( + filter(rootState.statuses.allStatuses, + status => status.user.id === userId && !preTickedIds.includes(status.id) + ) + ) + commit('openUserReportingModal', { userId, statuses, preTickedIds }) }, closeUserReportingModal ({ commit }) { commit('closeUserReportingModal') diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 206e6281..625f593e 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -201,7 +201,6 @@ export const parseUser = (data) => { // Convert punycode to unicode if (output.screen_name.includes('@')) { const parts = output.screen_name.split('@') - console.log(parts) let unicodeDomain = punycode.toUnicode(parts[1]) if (unicodeDomain !== parts[1]) { // Add some identifier so users can potentially spot spoofing attempts: -- cgit v1.2.3-70-g09d2