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

Commit 14aafff

Browse files
authored
Merge pull request #4200 from withspectrum/2.4.60
2.4.60
2 parents a0a54e3 + d29a0c0 commit 14aafff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+949
-548
lines changed

analytics/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"rethinkdbdash": "^2.3.29",
1818
"sanitize-filename": "^1.6.1",
1919
"sha1": "^1.1.1",
20-
"shortid": "^2.2.13",
20+
"shortid": "^2.2.14",
2121
"source-map-support": "^0.5.9",
2222
"toobusy-js": "^0.5.1"
2323
}

analytics/yarn.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ [email protected]:
347347
version "2.0.0"
348348
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
349349

350-
nanoid@^1.0.7:
351-
version "1.3.1"
352-
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-1.3.1.tgz#4538e1a02822b131da198d8eb17c9e3b3ac5167f"
350+
nanoid@^2.0.0:
351+
version "2.0.0"
352+
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.0.0.tgz#e1ab4a4b024a38d15531ba34a712a201540de639"
353353

354354
node-env-file@^0.1.8:
355355
version "0.1.8"
@@ -464,11 +464,11 @@ sha1@^1.1.1:
464464
charenc ">= 0.0.1"
465465
crypt ">= 0.0.1"
466466

467-
shortid@^2.2.13:
468-
version "2.2.13"
469-
resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.13.tgz#b2441e71c664ace458a341d343959f677910ef5b"
467+
shortid@^2.2.14:
468+
version "2.2.14"
469+
resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.14.tgz#80db6aafcbc3e3a46850b3c88d39e051b84c8d18"
470470
dependencies:
471-
nanoid "^1.0.7"
471+
nanoid "^2.0.0"
472472

473473
source-map-support@^0.5.9:
474474
version "0.5.9"

api/models/community.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import getRandomDefaultPhoto from '../utils/get-random-default-photo';
77
import {
88
sendNewCommunityWelcomeEmailQueue,
99
_adminSendCommunityCreatedEmailQueue,
10+
searchQueue,
11+
trackQueue,
1012
} from 'shared/bull/queues';
11-
import { trackQueue } from 'shared/bull/queues';
1213
import { events } from 'shared/analytics';
1314
import type { DBCommunity, DBUser } from 'shared/types';
1415
import type { Timeframe } from './utils';
@@ -253,6 +254,12 @@ export const createCommunity = ({ input }: CreateCommunityInput, user: DBUser):
253254
context: { communityId: community.id },
254255
});
255256

257+
searchQueue.add({
258+
id: community.id,
259+
type: 'community',
260+
event: 'created'
261+
})
262+
256263
// send a welcome email to the community creator
257264
sendNewCommunityWelcomeEmailQueue.add({ user, community });
258265
// email brian with info about the community and owner
@@ -426,6 +433,12 @@ export const editCommunity = ({ input }: EditCommunityInput, userId: string): Pr
426433
});
427434
})
428435
.then(community => {
436+
searchQueue.add({
437+
id: community.id,
438+
type: 'community',
439+
event: 'edited'
440+
})
441+
429442
// if no file was uploaded, update the community with new string values
430443
if (!file && !coverFile) {
431444
return db
@@ -592,6 +605,12 @@ export const deleteCommunity = (communityId: string, userId: string): Promise<DB
592605
event: events.COMMUNITY_DELETED,
593606
context: { communityId },
594607
});
608+
609+
searchQueue.add({
610+
id: communityId,
611+
type: 'community',
612+
event: 'deleted'
613+
})
595614
});
596615
};
597616

api/models/message.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
sendDirectMessageNotificationQueue,
66
processReputationEventQueue,
77
_adminProcessToxicMessageQueue,
8+
trackQueue,
9+
searchQueue,
810
} from 'shared/bull/queues';
911
import { NEW_DOCUMENTS } from './utils';
1012
import { createChangefeed } from 'shared/changefeed-utils';
@@ -14,7 +16,6 @@ import {
1416
decrementMessageCount,
1517
} from './thread';
1618
import { events } from 'shared/analytics';
17-
import { trackQueue } from 'shared/bull/queues';
1819
import type { DBMessage } from 'shared/types';
1920

2021
export type MessageTypes = 'text' | 'media';
@@ -154,6 +155,11 @@ export const storeMessage = (message: Object, userId: string): Promise<DBMessage
154155
if (message.threadType === 'story') {
155156
await Promise.all([
156157
sendMessageNotificationQueue.add({ message }),
158+
searchQueue.add({
159+
id: message.id,
160+
type: 'message',
161+
event: 'created'
162+
}),
157163
processReputationEventQueue.add({
158164
userId,
159165
type: 'message created',
@@ -241,6 +247,13 @@ export const deleteMessage = (userId: string, messageId: string) => {
241247
message.threadType === 'story'
242248
? decrementMessageCount(message.threadId)
243249
: Promise.resolve(),
250+
message.threadType === 'story'
251+
? searchQueue.add({
252+
id: message.id,
253+
type: 'message',
254+
event: 'deleted',
255+
})
256+
: Promise.resolve(),
244257
]);
245258

246259
return message;
@@ -267,6 +280,15 @@ export const deleteMessagesInThread = async (threadId: string, userId: string) =
267280
});
268281
});
269282

283+
const searchPromises = messages.map(message => {
284+
if (message.threadType !== 'story') return null
285+
return searchQueue.add({
286+
id: message.id,
287+
type: 'message',
288+
event: 'deleted'
289+
})
290+
})
291+
270292
const deletePromise = db
271293
.table('messages')
272294
.getAll(threadId, { index: 'threadId' })
@@ -276,7 +298,11 @@ export const deleteMessagesInThread = async (threadId: string, userId: string) =
276298
})
277299
.run();
278300

279-
return await Promise.all([...trackingPromises, deletePromise]).then(() => {
301+
return await Promise.all([
302+
...trackingPromises,
303+
deletePromise,
304+
...searchPromises
305+
]).then(() => {
280306
return Promise.all(Array.from({ length: messages.length }).map(() => decrementMessageCount(threadId)))
281307
});
282308
};
@@ -337,6 +363,12 @@ export const editMessage = (message: EditInput, userId: string): Promise<DBMessa
337363
event: events.MESSAGE_EDITED,
338364
context: { messageId: message.id },
339365
});
366+
367+
searchQueue.add({
368+
id: message.id,
369+
type: 'message',
370+
event: 'edited'
371+
})
340372
}
341373

342374
return message;

api/models/thread.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// @flow
22
const { db } = require('shared/db');
33
import intersection from 'lodash.intersection';
4-
import { processReputationEventQueue } from 'shared/bull/queues';
4+
import {
5+
processReputationEventQueue,
6+
trackQueue,
7+
searchQueue,
8+
} from 'shared/bull/queues';
59
const { NEW_DOCUMENTS, parseRange } = require('./utils');
610
import { createChangefeed } from 'shared/changefeed-utils';
711
import { deleteMessagesInThread } from '../models/message';
@@ -10,7 +14,6 @@ import type { PaginationOptions } from '../utils/paginate-arrays';
1014
import type { DBThread, FileUpload } from 'shared/types';
1115
import type { Timeframe } from './utils';
1216
import { events } from 'shared/analytics';
13-
import { trackQueue } from 'shared/bull/queues';
1417

1518
export const getThread = (threadId: string): Promise<DBThread> => {
1619
return db
@@ -433,6 +436,12 @@ export const publishThread = (
433436
.then(result => {
434437
const thread = result.changes[0].new_val;
435438

439+
searchQueue.add({
440+
id: thread.id,
441+
type: 'thread',
442+
event: 'created',
443+
});
444+
436445
trackQueue.add({
437446
userId,
438447
event: events.THREAD_CREATED,
@@ -516,6 +525,12 @@ export const deleteThread = (threadId: string, userId: string): Promise<Boolean>
516525
.then(([result]) => {
517526
const thread = result.changes[0].new_val;
518527

528+
searchQueue.add({
529+
id: thread.id,
530+
type: 'thread',
531+
event: 'deleted'
532+
})
533+
519534
trackQueue.add({
520535
userId,
521536
event: events.THREAD_DELETED,
@@ -566,6 +581,12 @@ export const editThread = (input: EditThreadInput, userId: string, shouldUpdate:
566581
if (result.replaced === 1) {
567582
const thread = result.changes[0].new_val;
568583

584+
searchQueue.add({
585+
id: thread.id,
586+
type: 'thread',
587+
event: 'edited'
588+
})
589+
569590
trackQueue.add({
570591
userId,
571592
event: events.THREAD_EDITED,
@@ -632,6 +653,12 @@ export const moveThread = (id: string, channelId: string, userId: string) => {
632653
if (result.replaced === 1) {
633654
const thread = result.changes[0].new_val;
634655

656+
searchQueue.add({
657+
id: thread.id,
658+
type: 'thread',
659+
event: 'moved',
660+
});
661+
635662
trackQueue.add({
636663
userId,
637664
event: events.THREAD_MOVED,

api/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
"babel-plugin-transform-flow-strip-types": "^6.22.0",
1616
"babel-plugin-transform-object-rest-spread": "^6.23.0",
1717
"babel-preset-env": "^1.7.0",
18-
"backpack-core": "^0.8.1",
18+
"backpack-core": "^0.8.2",
1919
"body-parser": "^1.18.3",
2020
"bull": "3.3.10",
2121
"casual": "^1.5.12",
2222
"compression": "^1.7.3",
2323
"cookie-parser": "^1.4.3",
2424
"cookie-session": "^2.0.0-beta.3",
25-
"cors": "^2.8.3",
25+
"cors": "^2.8.5",
2626
"cryptr": "^3.0.0",
2727
"dataloader": "^1.4.0",
2828
"debounce": "^1.2.0",
@@ -114,8 +114,8 @@
114114
"sanitize-filename": "^1.6.1",
115115
"serialize-javascript": "^1.5.0",
116116
"session-rethinkdb": "^2.0.0",
117-
"shortid": "^2.2.13",
118-
"slate": "^0.43.3",
117+
"shortid": "^2.2.14",
118+
"slate": "^0.43.6",
119119
"slate-markdown": "0.1.0",
120120
"slugg": "^1.1.0",
121121
"string-replace-to-array": "^1.0.3",

api/queries/directMessageThread/snippet.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default async (
1717
return loaders.directMessageSnippet.load(id).then(results => {
1818
if (!results) return 'No messages yet...';
1919
const message = results.reduction;
20+
if (message.messageType === 'media') return '📷 Photo';
2021
return message.messageType === 'draftjs'
2122
? toPlainText(toState(JSON.parse(message.content.body)))
2223
: message.content.body;

api/yarn.lock

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,9 +1940,9 @@ babel-polyfill@^6.26.0:
19401940
core-js "^2.5.0"
19411941
regenerator-runtime "^0.10.5"
19421942

1943-
babel-preset-backpack@^0.8.1:
1944-
version "0.8.1"
1945-
resolved "https://registry.yarnpkg.com/babel-preset-backpack/-/babel-preset-backpack-0.8.1.tgz#888f971167fbb689fd4f3cbffdb9a79098235925"
1943+
babel-preset-backpack@^0.8.2:
1944+
version "0.8.2"
1945+
resolved "https://registry.yarnpkg.com/babel-preset-backpack/-/babel-preset-backpack-0.8.2.tgz#c27197249a78e28c9ce7513e15508bd54f593bcf"
19461946
dependencies:
19471947
"@babel/core" "^7.0.0"
19481948
"@babel/plugin-proposal-class-properties" "^7.0.0"
@@ -2057,13 +2057,13 @@ backo2@^1.0.2:
20572057
version "1.0.2"
20582058
resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947"
20592059

2060-
backpack-core@^0.8.1:
2061-
version "0.8.1"
2062-
resolved "https://registry.yarnpkg.com/backpack-core/-/backpack-core-0.8.1.tgz#ead72b5557c90d023e45610f3ff5f5331e1f90ba"
2060+
backpack-core@^0.8.2:
2061+
version "0.8.2"
2062+
resolved "https://registry.yarnpkg.com/backpack-core/-/backpack-core-0.8.2.tgz#d8ef661ecbee43a87bce1888603a54eee8490873"
20632063
dependencies:
20642064
"@babel/core" "^7.1.2"
20652065
babel-loader "^8.0.2"
2066-
babel-preset-backpack "^0.8.1"
2066+
babel-preset-backpack "^0.8.2"
20672067
cross-spawn "^5.0.1"
20682068
friendly-errors-webpack-plugin "^1.7.0"
20692069
json-loader "^0.5.7"
@@ -2857,13 +2857,20 @@ [email protected], core-util-is@~1.0.0:
28572857
version "1.0.2"
28582858
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
28592859

2860-
cors@^2.8.3, cors@^2.8.4:
2860+
cors@^2.8.4:
28612861
version "2.8.4"
28622862
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.4.tgz#2bd381f2eb201020105cd50ea59da63090694686"
28632863
dependencies:
28642864
object-assign "^4"
28652865
vary "^1"
28662866

2867+
cors@^2.8.5:
2868+
version "2.8.5"
2869+
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
2870+
dependencies:
2871+
object-assign "^4"
2872+
vary "^1"
2873+
28672874
28682875
version "3.4.4"
28692876
resolved "https://registry.yarnpkg.com/crc/-/crc-3.4.4.tgz#9da1e980e3bd44fc5c93bf5ab3da3378d85e466b"
@@ -6219,9 +6226,9 @@ nan@^2.9.2:
62196226
version "2.11.1"
62206227
resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.1.tgz#90e22bccb8ca57ea4cd37cc83d3819b52eea6766"
62216228

6222-
nanoid@^1.0.7:
6223-
version "1.1.0"
6224-
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-1.1.0.tgz#b18e806e1cdbfdbe030374d5cf08a48cbc80b474"
6229+
nanoid@^2.0.0:
6230+
version "2.0.0"
6231+
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.0.0.tgz#e1ab4a4b024a38d15531ba34a712a201540de639"
62256232

62266233
nanomatch@^1.2.5:
62276234
version "1.2.7"
@@ -7943,11 +7950,11 @@ shellwords@^0.1.1:
79437950
version "0.1.1"
79447951
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
79457952

7946-
shortid@^2.2.13:
7947-
version "2.2.13"
7948-
resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.13.tgz#b2441e71c664ace458a341d343959f677910ef5b"
7953+
shortid@^2.2.14:
7954+
version "2.2.14"
7955+
resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.14.tgz#80db6aafcbc3e3a46850b3c88d39e051b84c8d18"
79497956
dependencies:
7950-
nanoid "^1.0.7"
7957+
nanoid "^2.0.0"
79517958

79527959
signal-exit@^3.0.0, signal-exit@^3.0.2:
79537960
version "3.0.2"
@@ -7965,9 +7972,9 @@ [email protected]:
79657972
react "^0.14.0 || ^15.0.0"
79667973
styled-components "^2.0.0"
79677974

7968-
slate@^0.43.3:
7969-
version "0.43.3"
7970-
resolved "https://registry.yarnpkg.com/slate/-/slate-0.43.3.tgz#7a71d95a8b3f5e7ed33120020e66d1eadc0ee699"
7975+
slate@^0.43.6:
7976+
version "0.43.6"
7977+
resolved "https://registry.yarnpkg.com/slate/-/slate-0.43.6.tgz#f42934dc041bd52ea23bf7190b51cb8f84867fe6"
79717978
dependencies:
79727979
debug "^3.1.0"
79737980
direction "^0.1.5"

athena/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"redis-tag-cache": "^1.2.1",
2121
"rethinkdbdash": "^2.3.31",
2222
"sanitize-filename": "^1.6.1",
23-
"shortid": "^2.2.13",
23+
"shortid": "^2.2.14",
2424
"source-map-support": "^0.4.18",
2525
"toobusy-js": "^0.5.1",
2626
"validator": "^9.4.1",

0 commit comments

Comments
 (0)