From 5f0ed256d6b5cbfd62074141986483e625c856e2 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 4 Mar 2021 16:36:22 +0100 Subject: [PATCH 01/16] set expiresIn of JWT to 2 years --- backend/src/jwt/encode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/jwt/encode.js b/backend/src/jwt/encode.js index 9126f2577..50e439474 100644 --- a/backend/src/jwt/encode.js +++ b/backend/src/jwt/encode.js @@ -5,7 +5,7 @@ import CONFIG from './../config' export default function encode(user) { const { id, name, slug } = user const token = jwt.sign({ id, name, slug }, CONFIG.JWT_SECRET, { - expiresIn: '1d', + expiresIn: '2y', issuer: CONFIG.GRAPHQL_URI, audience: CONFIG.CLIENT_URI, subject: user.id.toString(), From ff50273f94eaaad77caef9dd26197e10906a3b93 Mon Sep 17 00:00:00 2001 From: ashleysylvialee <72893506+ashleysylvialee@users.noreply.github.com> Date: Thu, 18 Mar 2021 22:32:27 -1000 Subject: [PATCH 02/16] =?UTF-8?q?fix:=20=F0=9F=8D=B0=20Suggestion=20List?= =?UTF-8?q?=20Filter=20(#4296)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix suggestion list filter * fix tests after MAPBOX changed their IDs again * Add spacebar selection functionality for mentions * Add tests * Fix linting Co-authored-by: Moriz Wahl Co-authored-by: Wolfgang Huß --- .../schema/resolvers/users/location.spec.js | 42 +++++++++++++++---- webapp/components/Editor/Editor.spec.js | 31 ++++++++++++++ webapp/components/Editor/Editor.vue | 12 +++++- 3 files changed, 74 insertions(+), 11 deletions(-) diff --git a/backend/src/schema/resolvers/users/location.spec.js b/backend/src/schema/resolvers/users/location.spec.js index 41b784249..1ef427034 100644 --- a/backend/src/schema/resolvers/users/location.spec.js +++ b/backend/src/schema/resolvers/users/location.spec.js @@ -114,10 +114,22 @@ describe('Location Service', () => { const result = await query({ query: queryLocations, variables }) expect(result.data.queryLocations).toEqual([ { id: 'place.14094307404564380', place_name: 'Berlin, Germany' }, - { id: 'place.15095411613564380', place_name: 'Berlin, Maryland, United States' }, - { id: 'place.5225018734564380', place_name: 'Berlin, Connecticut, United States' }, - { id: 'place.16922023226564380', place_name: 'Berlin, New Jersey, United States' }, - { id: 'place.4035845612564380', place_name: 'Berlin Township, New Jersey, United States' }, + { + id: expect.stringMatching(/^place\.[0-9]+$/), + place_name: 'Berlin, Maryland, United States', + }, + { + id: expect.stringMatching(/^place\.[0-9]+$/), + place_name: 'Berlin, Connecticut, United States', + }, + { + id: expect.stringMatching(/^place\.[0-9]+$/), + place_name: 'Berlin, New Jersey, United States', + }, + { + id: expect.stringMatching(/^place\.[0-9]+$/), + place_name: 'Berlin Township, New Jersey, United States', + }, ]) }) @@ -128,11 +140,23 @@ describe('Location Service', () => { } const result = await query({ query: queryLocations, variables }) expect(result.data.queryLocations).toEqual([ - { id: 'place.14094307404564380', place_name: 'Berlin, Deutschland' }, - { id: 'place.15095411613564380', place_name: 'Berlin, Maryland, Vereinigte Staaten' }, - { id: 'place.16922023226564380', place_name: 'Berlin, New Jersey, Vereinigte Staaten' }, - { id: 'place.10735893248465990', place_name: 'Berlin Heights, Ohio, Vereinigte Staaten' }, - { id: 'place.1165756679564380', place_name: 'Berlin, Massachusetts, Vereinigte Staaten' }, + { id: expect.stringMatching(/^place\.[0-9]+$/), place_name: 'Berlin, Deutschland' }, + { + id: expect.stringMatching(/^place\.[0-9]+$/), + place_name: 'Berlin, Maryland, Vereinigte Staaten', + }, + { + id: expect.stringMatching(/^place\.[0-9]+$/), + place_name: 'Berlin, New Jersey, Vereinigte Staaten', + }, + { + id: expect.stringMatching(/^place\.[0-9]+$/), + place_name: 'Berlin Heights, Ohio, Vereinigte Staaten', + }, + { + id: expect.stringMatching(/^place\.[0-9]+$/), + place_name: 'Berlin, Massachusetts, Vereinigte Staaten', + }, ]) }) diff --git a/webapp/components/Editor/Editor.spec.js b/webapp/components/Editor/Editor.spec.js index ee762b332..f51c5782f 100644 --- a/webapp/components/Editor/Editor.spec.js +++ b/webapp/components/Editor/Editor.spec.js @@ -99,6 +99,37 @@ describe('Editor.vue', () => { }) }) + it('suggestion list returns results prefixed by query', () => { + const manyUsersList = [] + for (let i = 0; i < 10; i++) { + manyUsersList.push({ id: `user${i}` }) + manyUsersList.push({ id: `admin${i}` }) + manyUsersList.push({ id: `moderator${i}` }) + } + propsData.users = manyUsersList + wrapper = Wrapper() + const suggestionList = wrapper.vm.editor.extensions.options.mention.onFilter( + propsData.users, + 'moderator', + ) + expect(suggestionList).toHaveLength(10) + for (var i = 0; i < suggestionList.length; i++) { + expect(suggestionList[i].id).toMatch(/^moderator.*/) + } + }) + + it('exact match appears at the top of suggestion list', () => { + const manyUsersList = [] + for (let i = 0; i < 25; i++) { + manyUsersList.push({ id: `user${i}` }) + } + propsData.users = manyUsersList + wrapper = Wrapper() + expect( + wrapper.vm.editor.extensions.options.mention.onFilter(propsData.users, 'user7')[0].id, + ).toMatch('user7') + }) + it('sets the Hashtag items to the hashtags', () => { propsData.hashtags = [ { diff --git a/webapp/components/Editor/Editor.vue b/webapp/components/Editor/Editor.vue index 67329a60b..cf0fd710b 100644 --- a/webapp/components/Editor/Editor.vue +++ b/webapp/components/Editor/Editor.vue @@ -185,6 +185,9 @@ export default { if (this.suggestionType === HASHTAG && this.query !== '') { this.selectItem({ id: this.query }) } + if (this.suggestionType === MENTION && item) { + this.selectItem(item) + } return true default: @@ -199,9 +202,14 @@ export default { const filteredList = items.filter((item) => { const itemString = item.slug || item.id - return itemString.toLowerCase().includes(query.toLowerCase()) + return itemString.toLowerCase().startsWith(query.toLowerCase()) }) - return filteredList.slice(0, 15) + const sortedList = filteredList.sort((itemA, itemB) => { + const aString = itemA.slug || itemA.id + const bString = itemB.slug || itemB.id + return aString.length - bString.length + }) + return sortedList.slice(0, 15) }, sanitizeQuery(query) { if (this.suggestionType === HASHTAG) { From e6dc3f42cedaf9953d737cf30cf7ed317b634be7 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 16 Mar 2021 10:36:07 +0100 Subject: [PATCH 03/16] setting up invite button --- .../components/InviteButton/InviteButton.vue | 17 ++ webapp/config/index.js | 2 + webapp/layouts/default.vue | 192 ++++++++++-------- 3 files changed, 122 insertions(+), 89 deletions(-) create mode 100644 webapp/components/InviteButton/InviteButton.vue diff --git a/webapp/components/InviteButton/InviteButton.vue b/webapp/components/InviteButton/InviteButton.vue new file mode 100644 index 000000000..57c60c8e4 --- /dev/null +++ b/webapp/components/InviteButton/InviteButton.vue @@ -0,0 +1,17 @@ + + + diff --git a/webapp/config/index.js b/webapp/config/index.js index fd564f350..678239729 100644 --- a/webapp/config/index.js +++ b/webapp/config/index.js @@ -29,6 +29,8 @@ const sentry = { const options = { VERSION: process.env.VERSION || pkg.version, DESCRIPTION: process.env.DESCRIPTION || pkg.description, + PUBLIC_REGISTRATION: process.env.PUBLIC_REGISTRATION === 'true', + INVITE_REGISTRATION: process.env.INVITE_REGISTRATION === 'true', // Cookies COOKIE_EXPIRE_TIME: process.env.COOKIE_EXPIRE_TIME || 730, // Two years by default COOKIE_HTTPS_ONLY: process.env.COOKIE_HTTPS_ONLY || process.env.NODE_ENV === 'production', // ensure true in production if not set explicitly diff --git a/webapp/layouts/default.vue b/webapp/layouts/default.vue index 0bf98967e..e666d5e44 100644 --- a/webapp/layouts/default.vue +++ b/webapp/layouts/default.vue @@ -40,9 +40,9 @@