Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.
Merged

v2.4.17 #3479

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
ce11863
Potential athena race condition fix
mxstbr May 31, 2018
c50750a
ajust desctop draggable region area
ryota-murakami May 31, 2018
46cb99d
Revert "ajust desctop draggable region area"
ryota-murakami Jun 2, 2018
95cfc00
fix <MessagesTab /> usage
ryota-murakami Jun 2, 2018
1decbfc
change icon to no-draggable
ryota-murakami Jun 2, 2018
a23f94d
against dangerJS
ryota-murakami Jun 2, 2018
618f3fc
Fix email validation email redirects for users without usernames
brianlovin Jun 26, 2018
fbc0151
Cache external JS files (Amplitude, GA)
mxstbr Jun 27, 2018
0c52d3c
Update react-hot-loader to version 4.3.3
depfu[bot] Jun 28, 2018
80b7740
Update babel-eslint to version 8.2.5
depfu[bot] Jun 28, 2018
badd6d1
Update web-push to version 3.3.2
depfu[bot] Jun 28, 2018
35d6734
Merge pull request #3408 from withspectrum/depfu/update/yarn/react-ho…
brianlovin Jun 29, 2018
1a01dff
Merge pull request #3409 from withspectrum/depfu/update/yarn/babel-es…
brianlovin Jun 29, 2018
67377f2
Upgrade slate-markdown to version 0.1.1
depfu[bot] Jun 29, 2018
20d1388
Merge pull request #3410 from withspectrum/depfu/update/yarn/web-push…
brianlovin Jun 29, 2018
275ee88
Update react-popper to version 1.0.0
depfu[bot] Jun 29, 2018
fe65316
Update react-apollo to version 2.1.8
depfu[bot] Jun 29, 2018
be47b61
Update offline-plugin to version 5.0.5
depfu[bot] Jun 29, 2018
2711c07
Update moment to version 2.22.2
depfu[bot] Jun 29, 2018
df0b595
Update lodash to version 4.17.10
depfu[bot] Jun 29, 2018
361bb11
Update babel-jest to version 22.4.4
depfu[bot] Jun 29, 2018
2176d3d
Show "Team" on badges for moderators and admins
mxstbr Jun 29, 2018
290d742
Merge pull request #3414 from withspectrum/depfu/update/yarn/react-po…
brianlovin Jun 29, 2018
98ed8e9
Merge pull request #3415 from withspectrum/depfu/update/yarn/react-ap…
brianlovin Jun 29, 2018
76a02b4
Merge pull request #3416 from withspectrum/depfu/update/yarn/offline-…
brianlovin Jun 29, 2018
e2cf4dd
Merge pull request #3417 from withspectrum/depfu/update/yarn/moment-2…
brianlovin Jun 29, 2018
3fd8592
Merge branch 'alpha' into depfu/update/yarn/lodash-4.17.10
brianlovin Jun 29, 2018
71bae34
Merge pull request #3420 from withspectrum/peer-pressure-ftw
brianlovin Jun 29, 2018
37424b6
Merge pull request #3419 from withspectrum/depfu/update/yarn/babel-je…
brianlovin Jun 29, 2018
8c0ed01
Merge pull request #3413 from withspectrum/depfu/update/yarn/slate-ma…
brianlovin Jun 29, 2018
2e8f0b0
Fix icon and text alignment on thread cards
brianlovin Jun 29, 2018
944a994
Update hoist-non-react-statics to version 2.5.5
depfu[bot] Jun 29, 2018
3c8cb93
Merge pull request #3421 from withspectrum/polish-icon-alignments
brianlovin Jun 29, 2018
d3c7c9a
Merge pull request #3395 from withspectrum/fix-email-unsub-without-us…
brianlovin Jun 29, 2018
890e6d5
Merge pull request #3396 from withspectrum/cache-external-js
brianlovin Jun 29, 2018
fdcd10b
Merge pull request #3418 from withspectrum/depfu/update/yarn/lodash-4…
brianlovin Jun 29, 2018
1c995c7
Update graphql-tools to version 3.0.4
depfu[bot] Jun 29, 2018
09ceef3
Upgrade graphql-subscriptions to version 0.5.8
depfu[bot] Jun 29, 2018
1d14327
Merge pull request #3427 from withspectrum/depfu/update/yarn/graphql-…
brianlovin Jun 29, 2018
4a5567f
Merge pull request #3426 from withspectrum/depfu/update/yarn/graphql-…
brianlovin Jun 29, 2018
9f968ad
Upgrade graphql-server-express to version 1.3.6
depfu[bot] Jun 29, 2018
552fb4c
Merge pull request #3422 from withspectrum/depfu/update/yarn/hoist-no…
brianlovin Jun 29, 2018
e7b36b0
Update helmet to version 3.12.1
depfu[bot] Jun 29, 2018
a0360ca
Merge pull request #3428 from withspectrum/depfu/update/yarn/graphql-…
brianlovin Jun 29, 2018
feea0ee
Merge branch 'alpha' into depfu/update/yarn/helmet-3.12.1
brianlovin Jun 29, 2018
842cc8b
Upgrade graphql-log to version 0.1.3
depfu[bot] Jun 29, 2018
b4f04e3
Merge pull request #3424 from withspectrum/depfu/update/yarn/helmet-3…
brianlovin Jun 29, 2018
9001d87
Merge pull request #3429 from withspectrum/depfu/update/yarn/graphql-…
brianlovin Jun 29, 2018
57d7789
Update body-parser to version 1.18.3
depfu[bot] Jun 29, 2018
3976778
Upgrade draft-js-image-plugin to version 2.0.5
depfu[bot] Jun 29, 2018
e2bf8f4
Merge pull request #3431 from withspectrum/depfu/update/yarn/body-par…
brianlovin Jun 29, 2018
7a66106
Upgrade draft-js-drag-n-drop-plugin to version 2.0.3
depfu[bot] Jun 29, 2018
35ac327
Update subscriptions-transport-ws to version 0.9.12
depfu[bot] Jun 30, 2018
c3b81b5
Update webpack-bundle-analyzer to version 2.13.1
depfu[bot] Jun 30, 2018
c6c1b3e
Merge pull request #3434 from withspectrum/depfu/update/yarn/subscrip…
brianlovin Jun 30, 2018
c42f996
Merge pull request #3433 from withspectrum/depfu/update/yarn/draft-js…
brianlovin Jun 30, 2018
2835af0
Merge pull request #3432 from withspectrum/depfu/update/yarn/draft-js…
brianlovin Jun 30, 2018
ab58ebf
Merge pull request #3435 from withspectrum/depfu/update/yarn/webpack-…
brianlovin Jun 30, 2018
2f6dc11
Update eslint-plugin-promise to version 3.8.0
depfu[bot] Jun 30, 2018
774a784
Merge pull request #3438 from withspectrum/depfu/update/yarn/eslint-p…
brianlovin Jun 30, 2018
b81ebde
Update eslint-plugin-react to version 7.10.0
depfu[bot] Jun 30, 2018
b02eec0
Update eslint-plugin-jest to version 21.17.0
depfu[bot] Jun 30, 2018
d1e3875
Update eslint-plugin-flowtype to version 2.49.3
depfu[bot] Jun 30, 2018
5821a43
Update cross-env to version 5.2.0
depfu[bot] Jun 30, 2018
13ecdad
Merge pull request #3442 from withspectrum/depfu/update/yarn/cross-en…
brianlovin Jul 1, 2018
ae0bf39
Merge pull request #3441 from withspectrum/depfu/update/yarn/eslint-p…
brianlovin Jul 1, 2018
4456755
Merge pull request #3439 from withspectrum/depfu/update/yarn/eslint-p…
brianlovin Jul 1, 2018
60426e0
Update eslint-plugin-import to version 2.13.0
depfu[bot] Jul 1, 2018
df71899
Merge pull request #3437 from withspectrum/depfu/update/yarn/eslint-p…
brianlovin Jul 1, 2018
038ab7d
Fix push notification formatting for thread reactions
brianlovin Jul 1, 2018
abae55d
Merge pull request #3440 from withspectrum/depfu/update/yarn/eslint-p…
brianlovin Jul 1, 2018
2d97579
Update babel-preset-env to version 1.7.0
depfu[bot] Jul 1, 2018
9d42998
Upgrade styled-components to version 3.3.3
depfu[bot] Jul 1, 2018
dd8ad63
Merge pull request #3445 from withspectrum/depfu/update/yarn/babel-pr…
brianlovin Jul 1, 2018
b0c00b3
Match chat input text size to bubble text size
brianlovin Jul 1, 2018
88e2693
Fix thread selected state in inbox on mobile
brianlovin Jul 1, 2018
2ef6b7a
Adds online indicators to thread feed cards
brianlovin Jul 1, 2018
fa72ed1
Add pseudo read/unread state to thread feed items
brianlovin Jul 1, 2018
81ff06a
Update serialize-javascript to version 1.5.0
depfu[bot] Jul 1, 2018
d6f02ea
Merge pull request #3453 from withspectrum/depfu/update/yarn/serializ…
brianlovin Jul 1, 2018
49a41f5
Merge pull request #3447 from withspectrum/depfu/update/yarn/styled-c…
brianlovin Jul 1, 2018
cff1287
Update request to version 2.87.0
depfu[bot] Jul 1, 2018
5f93ee2
Refocus chat input whenever the quote message prop changes
brianlovin Jul 1, 2018
71a635f
Keep buttons the same size when loading
brianlovin Jul 1, 2018
1f7ca83
Fix flow
brianlovin Jul 1, 2018
9ccd859
Merge pull request #3454 from withspectrum/depfu/update/yarn/request-…
brianlovin Jul 1, 2018
4aa8b3a
Update redux-thunk to version 2.3.0
depfu[bot] Jul 2, 2018
f1e0ec2
Merge pull request #3236 from ryota-murakami/feature/ajust-desctop-dr…
brianlovin Jul 2, 2018
60fe108
Merge pull request #3449 from withspectrum/fix-chatinput-text-size
mxstbr Jul 2, 2018
3e04c2e
Merge pull request #3443 from withspectrum/fix-thread-like-notifications
mxstbr Jul 2, 2018
4e67460
Merge pull request #3450 from withspectrum/fix-thread-selected-state-…
mxstbr Jul 2, 2018
c9d83db
Merge pull request #3452 from withspectrum/small-thread-card-improvem…
mxstbr Jul 2, 2018
788773b
Merge pull request #3455 from withspectrum/fix-reply-focus
mxstbr Jul 2, 2018
514b6a7
Merge pull request #3456 from withspectrum/fix-button-resize-on-loading
mxstbr Jul 2, 2018
6a16a6a
Fix HMR error
mxstbr Jul 2, 2018
2452209
Fix thread message pagination in long threads
mxstbr Jul 2, 2018
3d9fbe7
Update to draft-js-markdown-plugin v3
mxstbr Jul 2, 2018
2832791
Merge pull request #3462 from withspectrum/fix-thread-message-pagination
brianlovin Jul 2, 2018
ad10b3e
Merge pull request #3463 from withspectrum/update-markdown-plugin-to-…
brianlovin Jul 2, 2018
51db70f
Merge pull request #3460 from withspectrum/fix-hmr
mxstbr Jul 2, 2018
cd6c64c
Upgrade recompose to version 0.27.1
depfu[bot] Jul 2, 2018
fa9d9f4
Merge pull request #3466 from withspectrum/depfu/update/yarn/recompos…
brianlovin Jul 3, 2018
e0612ba
Update react-transition-group to version 2.4.0
depfu[bot] Jul 3, 2018
022193f
Merge pull request #3458 from withspectrum/depfu/update/yarn/redux-th…
brianlovin Jul 3, 2018
6d9a9db
Upgrade redraft to version 0.10.1
depfu[bot] Jul 3, 2018
d2f3412
Update react-router to version 4.3.1
depfu[bot] Jul 3, 2018
f59d75d
Rename moderators to team in community settings
mxstbr Jul 3, 2018
44f3e2b
Upsell adding team members on community view
mxstbr Jul 3, 2018
333c940
Fix moderator 404 copy
mxstbr Jul 3, 2018
6cbc6ca
Fix e2e tests
mxstbr Jul 3, 2018
6785903
Decrease message text size to 14px
mxstbr Jul 3, 2018
0179a80
14 => 15px
mxstbr Jul 3, 2018
b7ae67e
Merge pull request #3468 from withspectrum/depfu/update/yarn/react-ro…
mxstbr Jul 3, 2018
ac7166c
Merge pull request #3467 from withspectrum/depfu/update/yarn/react-tr…
mxstbr Jul 3, 2018
9d9a57a
Update react-modal to version 3.4.5
depfu[bot] Jul 3, 2018
bec90ed
Update raven to version 2.6.3
depfu[bot] Jul 3, 2018
ccd24f6
Merge pull request #3473 from withspectrum/depfu/update/yarn/raven-2.6.3
brianlovin Jul 4, 2018
01d9020
Merge pull request #3471 from withspectrum/depfu/update/yarn/react-mo…
brianlovin Jul 4, 2018
a2d1652
Merge pull request #3469 from withspectrum/moderators-team
brianlovin Jul 4, 2018
02e31b0
Merge pull request #3225 from withspectrum/athena-race-condition-fix
brianlovin Jul 4, 2018
02b0cfa
Merge pull request #3470 from withspectrum/decrease-message-text-size
brianlovin Jul 4, 2018
80cdf64
Merge pull request #3459 from withspectrum/depfu/update/yarn/redraft-…
brianlovin Jul 4, 2018
5f9697a
Update now-env to version 3.1.0
depfu[bot] Jul 4, 2018
48a1067
Merge pull request #3477 from withspectrum/depfu/update/yarn/now-env-…
mxstbr Jul 4, 2018
b8c66af
Merge branch 'alpha' into v2.4.17
mxstbr Jul 4, 2018
a1c5070
Version
mxstbr Jul 4, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions api/routes/api/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,13 @@ emailRouter.get('/validate', (req, res) => {

// and send a database request to update the user record with this email
try {
return updateUserEmail(userId, email).then(
user =>
IS_PROD
? res.redirect(
`https://spectrum.chat/users/${user.username}/settings`
)
: res.redirect(
`http://localhost:3000/users/${user.username}/settings`
)
);
return updateUserEmail(userId, email).then(user => {
const rootRedirect = IS_PROD
? `https://spectrum.chat`
: `http://localhost:3000`;
if (!user.username) return res.redirect(rootRedirect);
return res.redirect(`${rootRedirect}/users/${user.username}/settings`);
});
} catch (err) {
console.error(err);
return res
Expand Down
24 changes: 20 additions & 4 deletions athena/queues/new-message-in-thread/buffer-email.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,26 @@ const bufferMessageNotificationEmail = async (
thread.id
}`
);
const job = await bufferNewMessageEmailQueue.getJob(recipient.email);
let job = await bufferNewMessageEmailQueue.getJob(recipient.email);
// Try to remove the job if it exists. This fails sometimes due to a
// race condition where the getJob returns a failed or active job.
// We circumvent that issue by simply pretending like no job exists
// and adding a new one
// Ref: withspectrum/spectrum#3189
if (job) {
debug(`timeout exists for ${recipient.email}, clearing`);
try {
await job.remove();
} catch (err) {
try {
await job.finished();
// Note(@mxstbr): This throws if the job fails to complete
// but we don't care if that happens, so we ignore it
} catch (err) {}

job = null;
}
}
if (!job) {
debug(
`creating new timeout for ${
Expand All @@ -185,9 +204,6 @@ const bufferMessageNotificationEmail = async (
);
} else {
const timeout = job.data;
// If we already have a timeout going
debug(`timeout exists for ${recipient.email}, clearing`);
await job.remove();
debug(`adding new thread to ${recipient.email}'s threads`);
timeout.threads.push(thread);
timeout.notifications.push(notification);
Expand Down
5 changes: 4 additions & 1 deletion config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ module.exports = function override(config, env) {
plugin => !isServiceWorkerPlugin(plugin)
);
// Get all public files so they're cached by the SW
let externals = [];
let externals = [
'https://www.google-analytics.com/analytics.js',
'https://cdn.amplitude.com/libs/amplitude-4.2.1-min.gz.js',
];
walkFolder('./public/', file => {
// HOTFIX: Don't cache images
if (file.indexOf('img') > -1 && file.indexOf('homescreen-icon') === -1)
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/community_settings_billing_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('Community settings billing tab', () => {
// click the moderator item in dropdown
cy
.get('[data-cy="community-settings-members-list"]')
.contains('Can edit and delete conversations')
.contains('can moderate conversations')
.click();

// admin email verification modal should appear
Expand Down Expand Up @@ -252,7 +252,7 @@ describe('Community settings billing tab', () => {
// click the moderator item in dropdown
cy
.get('[data-cy="community-settings-members-list"]')
.contains('Can edit and delete conversations')
.contains('can moderate conversations')
.click();

// admin email verification modal should appear
Expand Down
70 changes: 35 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "Spectrum",
"version": "2.4.16",
"version": "2.4.17",
"license": "BSD-3-Clause",
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-eslint": "^8.2.2",
"babel-jest": "^22.4.3",
"babel-eslint": "^8.2.5",
"babel-jest": "^22.4.4",
"babel-plugin-import-inspector": "^2.0.0",
"babel-plugin-inline-import-graphql-ast": "^2.0.4",
"babel-plugin-styled-components": "^1.1.7",
Expand All @@ -15,19 +15,19 @@
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.5.2",
"babel-preset-env": "^1.7.0",
"backpack-core": "^0.4.1",
"bundle-buddy-webpack-plugin": "^0.3.0",
"cheerio": "^1.0.0-rc.2",
"cross-env": "^5.0.5",
"cross-env": "^5.2.0",
"eslint": "^4.1.1",
"eslint-config-react-app": "^2.1.0",
"eslint-plugin-flowtype": "^2.34.1",
"eslint-plugin-import": "^2.6.0",
"eslint-plugin-flowtype": "^2.49.3",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jest": "^21.6.1",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-react": "^7.10.0",
"flow-bin": "0.66",
"forever": "^0.15.3",
"is-html": "^1.1.0",
Expand All @@ -36,13 +36,13 @@
"prettier": "^1.0.0",
"raw-loader": "^0.5.1",
"react-app-rewire-hot-loader": "^1.0.1",
"react-hot-loader": "^4.3.1",
"react-hot-loader": "^4.3.3",
"react-scripts": "^1.0.0",
"rimraf": "^2.6.1",
"sw-precache-webpack-plugin": "^0.11.4",
"uuid": "^3.0.1",
"wait-on": "^2.1.0",
"webpack-bundle-analyzer": "^2.9.1",
"webpack-bundle-analyzer": "^2.13.1",
"write-file-webpack-plugin": "^4.3.2"
},
"dependencies": {
Expand All @@ -63,7 +63,7 @@
"aws-sdk": "2.200.0",
"axios": "^0.17.1",
"bad-words": "^1.6.1",
"body-parser": "^1.17.1",
"body-parser": "^1.18.3",
"bull": "3.3.10",
"casual": "^1.5.19",
"common-tags": "^1.7.2",
Expand All @@ -78,13 +78,13 @@
"debug": "^2.6.8",
"draft-js": "npm:draft-js-fork-mxstbr",
"draft-js-code-editor-plugin": "0.2.1",
"draft-js-drag-n-drop-plugin": "2.0.0-rc9",
"draft-js-drag-n-drop-plugin": "^2.0.3",
"draft-js-embed-plugin": "^1.2.0",
"draft-js-focus-plugin": "2.0.0-rc2",
"draft-js-image-plugin": "2.0.0-rc8",
"draft-js-image-plugin": "^2.0.5",
"draft-js-import-markdown": "^1.2.1",
"draft-js-linkify-plugin": "^2.0.0-beta1",
"draft-js-markdown-plugin": "^2.1.0",
"draft-js-markdown-plugin": "^3.0.0",
"draft-js-plugins-editor": "^2.0.4",
"draft-js-prism-plugin": "0.1.3",
"draftjs-to-markdown": "^0.4.2",
Expand All @@ -101,12 +101,12 @@
"graphql-cost-analysis": "^0.1.1",
"graphql-date": "^1.0.3",
"graphql-depth-limit": "^1.1.0",
"graphql-log": "0.1.2",
"graphql-server-express": "1.3.0",
"graphql-subscriptions": "0.5.6",
"graphql-log": "0.1.3",
"graphql-server-express": "1.3.6",
"graphql-subscriptions": "0.5.8",
"graphql-tag": "^2.9.2",
"graphql-tools": "^3.0.2",
"helmet": "^3.12.0",
"graphql-tools": "^3.0.4",
"helmet": "^3.12.1",
"highlight.js": "^9.10.0",
"history": "^4.6.1",
"hoist-non-react-statics": "^2.3.1",
Expand All @@ -121,13 +121,13 @@
"jsonwebtoken": "^8.0.1",
"keygrip": "^1.0.2",
"linkify-it": "^2.0.3",
"lodash": "^4.17.4",
"lodash": "^4.17.10",
"lodash.intersection": "^4.4.0",
"markdown-draft-js": "^0.6.3",
"moment": "^2.18.1",
"moment": "^2.22.2",
"node-env-file": "^0.1.8",
"now-env": "^3.0.1",
"offline-plugin": "^5.0.3",
"now-env": "^3.1.0",
"offline-plugin": "^5.0.5",
"optics-agent": "^1.1.2",
"passport": "^0.3.2",
"passport-facebook": "^2.1.1",
Expand All @@ -139,10 +139,10 @@
"prismjs": "^1.8.1",
"query-string": "^5.0.0",
"raf": "^3.4.0",
"raven": "^2.0.2",
"raven": "^2.6.3",
"raven-js": "^3.18.1",
"react": "^16.4.0",
"react-apollo": "^2.1.6",
"react-apollo": "^2.1.8",
"react-app-rewire-styled-components": "^3.0.0",
"react-app-rewired": "^1.5.2",
"react-clipboard.js": "^2.0.0",
Expand All @@ -159,36 +159,36 @@
"react-stripe-checkout": "^2.2.5",
"react-stripe-elements": "^1.4.1",
"react-textarea-autosize": "^6.1.0",
"react-transition-group": "^2.2.0",
"react-transition-group": "^2.4.0",
"react-trend": "^1.2.4",
"recompose": "0.26.x",
"redraft": "0.8.0",
"recompose": "^0.27.1",
"redraft": "0.10.1",
"redux": "^3.6.0",
"redux-thunk": "^2.2.0",
"request": "^2.85.0",
"redux-thunk": "^2.3.0",
"request": "^2.87.0",
"rethinkdb-changefeed-reconnect": "^0.3.2",
"rethinkdb-inspector": "^0.3.3",
"rethinkdb-migrate": "^1.1.0",
"rethinkdbdash": "^2.3.29",
"sanitize-filename": "^1.6.1",
"serialize-javascript": "^1.4.0",
"serialize-javascript": "^1.5.0",
"session-rethinkdb": "^2.0.0",
"sha1": "^1.1.1",
"shortid": "^2.2.8",
"slate": "^0.20.1",
"slate-markdown": "0.1.0",
"slate-markdown": "0.1.1",
"slugg": "^1.1.0",
"stopword": "^0.1.9",
"string-replace-to-array": "^1.0.3",
"string-similarity": "^1.2.0",
"stripe": "^4.15.0",
"striptags": "2.x",
"styled-components": "3.1.x",
"styled-components": "^3.3.3",
"subscriptions-transport-ws": "0.9.x",
"then-queue": "^1.3.0",
"toobusy-js": "^0.5.1",
"validator": "^9.0.0",
"web-push": "^3.2.2"
"web-push": "^3.3.2"
},
"resolutions": {
"immutable": "3.7.4",
Expand Down
1 change: 1 addition & 0 deletions shared/bull/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type Job<JobData> = {|
id: string,
data: JobData,
remove: () => Promise<void>,
finished: () => Promise<void>,
|};

type JobOptions = {|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const getThreadMessageConnectionOptions = {
};

// Any thread with less than 50 messages just load all of 'em
if (props.threadMessageCount >= 50) {
if (props.thread.messageCount >= 50) {
// If the thread was active after the user last saw it, only load the new messages
if (props.lastSeen) {
if (
Expand Down
35 changes: 21 additions & 14 deletions shared/notification-to-text.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import onlyContainsEmoji from 'shared/only-contains-emoji';
import sentencify from 'shared/sentencify';
import { timeDifferenceShort } from 'shared/time-difference';
import sortByDate from 'shared/sort-by-date';
import { toState, toPlainText } from 'shared/draft-utils';

Expand All @@ -16,13 +14,6 @@ const sortThreads = (entities, currentUser) => {
return threads;
};

// parse date => modifiedAt to timeAgo
const parseNotificationDate = date => {
const now = new Date().getTime();
const timestamp = new Date(date).getTime();
return timeDifferenceShort(now, timestamp);
};

export const parseActors = (actors, currentUser) => {
const filteredActors = actors
.filter(actor => actor.id !== currentUser.id)
Expand All @@ -31,12 +22,13 @@ export const parseActors = (actors, currentUser) => {
};

const EVENT_VERB = {
MESSAGE_CREATED: 'replied',
MESSAGE_CREATED: 'replied in',
REACTION_CREATED: 'liked',
CHANNEL_CREATED: 'created in',
USER_JOINED_COMMUNITY: 'joined',
MENTION_MESSAGE: 'mentioned you in',
MENTION_THREAD: 'mentioned you in',
THREAD_REACTION_CREATED: 'liked',
};

const contextToString = (context, currentUser) => {
Expand All @@ -45,18 +37,23 @@ const contextToString = (context, currentUser) => {
case 'THREAD': {
const payload = context.payload;
const isCreator = payload.creatorId === currentUser.id;
const str = isCreator ? 'in your thread' : 'in';
const str = isCreator ? 'your thread' : '';
return `${str} ${payload.content.title}`;
}
case 'DIRECT_MESSAGE_THREAD': {
return 'in a direct message thread';
}
case 'THREAD_REACTION': {
return 'your thread';
}
case 'MESSAGE':
return 'your reply';
case 'COMMUNITY':
return context.payload.name;
case 'CHANNEL':
return context.payload.name;
default:
return;
}
};

Expand Down Expand Up @@ -84,16 +81,13 @@ const parseNotification = notification => {

const formatNotification = (incomingNotification, currentUserId) => {
const notification = parseNotification(incomingNotification);

const actors =
notification.actors &&
parseActors(notification.actors, { id: currentUserId });
const event = notification.event && EVENT_VERB[notification.event];
const context =
notification.context &&
contextToString(notification.context, { id: currentUserId });
const date =
notification.modifiedAt && parseNotificationDate(notification.modifiedAt);

let title = `${actors} ${event} ${context}`;
let href, body;
Expand Down Expand Up @@ -171,6 +165,16 @@ const formatNotification = (incomingNotification, currentUserId) => {
: message.content.body;
break;
}
case 'THREAD_REACTION_CREATED': {
const thread = notification.context.payload;

href = `/thread/${thread.id}`;
body =
thread.type === 'draftjs'
? toPlainText(toState(thread.content.body))
: thread.content.body;
break;
}
case 'CHANNEL_CREATED': {
const entities = notification.entities;
const newChannelCount =
Expand All @@ -187,6 +191,7 @@ const formatNotification = (incomingNotification, currentUserId) => {
title = `${actors} ${event} ${context}`;
break;
}

case 'MENTION_THREAD': {
// sort and order the threads
const threads = sortThreads(notification.entities, { id: currentUserId });
Expand Down Expand Up @@ -221,6 +226,8 @@ const formatNotification = (incomingNotification, currentUserId) => {
title = `${actors} invited you to join their community, ${context}`;
break;
}
default:
return;
}

const data = href && {
Expand Down
Loading