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

2.8.2 #4809

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9065216
Add syntax highlighting for code blocks in messages
Feb 28, 2019
4703e28
Merge remote-tracking branch 'upstream/alpha' into message-syntax-hig…
Feb 28, 2019
b96d0a2
Add flow to files that were missing it
Feb 28, 2019
8c38f72
Refactor messageType to using a constant instead of relying on strings
Mar 1, 2019
e2d8786
Merge branch 'alpha' of github.com:withspectrum/spectrum into message…
brianlovin Mar 1, 2019
bc2bc87
Merge branch 'alpha' of github.com:withspectrum/spectrum into message…
brianlovin Mar 1, 2019
d36c044
Add language to code blocks when editing messages
Ponjimon Mar 2, 2019
cb68e69
Update ratelimiter to version 3.3.0
depfu[bot] Mar 3, 2019
612a9d1
Merge pull request #4788 from withspectrum/depfu/update/api/yarn/rate…
brianlovin Mar 3, 2019
9e4fbc1
Properly handle missing thread data while getting thread link
brianlovin Mar 4, 2019
9566a41
Merge pull request #4790 from withspectrum/hotfix-notifications-threa…
brianlovin Mar 4, 2019
fb5ced8
Revert "Add language to code blocks when editing messages"
Mar 4, 2019
885f898
Add project board to readme
mxstbr Mar 4, 2019
80fad2c
Merge pull request #4759 from lookapanda/message-syntax-highlighting
mxstbr Mar 4, 2019
51fedbf
Fix thread links across the board
Mar 4, 2019
2886ad5
Add support for lists to messages
Mar 4, 2019
8fc6379
Add new block types to test snapshot
brianlovin Mar 4, 2019
cead534
Use cypress retries
brianlovin Mar 4, 2019
d51957b
Merge pull request #4800 from withspectrum/test-retries
brianlovin Mar 4, 2019
3b6ff25
Merge branch 'alpha' of github.com:withspectrum/spectrum into message…
brianlovin Mar 4, 2019
436a3f1
Styling fixes
brianlovin Mar 4, 2019
57fc998
Remove ul ol bottom margin in messages
brianlovin Mar 4, 2019
bf90c19
Merge pull request #4797 from withspectrum/messages-lists
brianlovin Mar 4, 2019
f585110
Remove sam sentence logic
brianlovin Mar 4, 2019
7278278
Use emoji
brianlovin Mar 4, 2019
047dbc0
Merge pull request #4806 from withspectrum/fix-sam-text
brianlovin Mar 4, 2019
dc2287f
Merge pull request #4796 from withspectrum/fix-thread-links
brianlovin Mar 4, 2019
2b8afd9
Merge pull request #4793 from withspectrum/add-todos-to-readme
brianlovin Mar 4, 2019
0f46623
Break words in thread titles
brianlovin Mar 4, 2019
ed55b3c
Handle inbox thread title truncation when there are no spaces in the …
brianlovin Mar 4, 2019
3cd045e
Merge pull request #4807 from withspectrum/fix-title-wrapping
brianlovin Mar 4, 2019
a268a3c
Hide the placeholder composer on profile views on mobile
brianlovin Mar 4, 2019
067846e
Merge pull request #4808 from withspectrum/fix-placeholder-gap
brianlovin Mar 4, 2019
e885cc6
Merge branch 'alpha' of github.com:withspectrum/spectrum into 2.8.2
brianlovin Mar 4, 2019
a20f279
2.8.2
brianlovin Mar 4, 2019
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: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ It is difficult to grow, manage and measure the impact of online communities. Co

### Status

Spectrum has been in full-time development since March 2017 and is [part of GitHub since November 2018](https://spectrum.chat/spectrum/general/spectrum-is-joining-github~1d3eb8ee-4c99-46c0-8daf-ca35a96be6ce).
Spectrum has been in full-time development since March 2017 and is [part of GitHub since November 2018](https://spectrum.chat/spectrum/general/spectrum-is-joining-github~1d3eb8ee-4c99-46c0-8daf-ca35a96be6ce). See our current priorities and what we are working on in the [main project board](https://github.com/withspectrum/spectrum/projects/23).

<div align="center">
<img height="50px" src="public/img/cluster-1.svg" />
Expand Down Expand Up @@ -51,7 +51,7 @@ Spectrum has been in full-time development since March 2017 and is [part of GitH

## Contributing

**We heartily welcome any and all contributions that match [our product roadmap](https://github.com/withspectrum/spectrum/projects/19) and engineering standards!**
**We heartily welcome any and all contributions that match our engineering standards!**

That being said, this codebase isn't your typical open source project because it's not a library or package with a limited scope—it's our entire product.

Expand All @@ -67,7 +67,9 @@ If you found a technical bug on Spectrum or have ideas for features we should im

#### Fixing a bug or implementing a new feature

If you find a bug on Spectrum and open a PR that fixes it we'll review it as soon as possible to ensure it matches our engineering standards. If you want to implement a new feature, open an issue first to discuss what it'd look like and to ensure it fits in [our roadmap](https://github.com/withspectrum/spectrum/projects/19) and plans for the app.
If you find a bug on Spectrum and open a PR that fixes it we'll review it as soon as possible to ensure it matches our engineering standards.

If you want to implement a new feature, open an issue first to discuss what it'd look like and to ensure it fits in our roadmap and plans for the app (see [the main project board](https://github.com/withspectrum/spectrum/projects/23) for planned and currently ongoing work).

If you want to contribute but are unsure to start, we have [a "good first issue" label](https://github.com/withspectrum/spectrum/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) which is applied to newcomer-friendly issues. Take a look at [the full list of good first issues](https://github.com/withspectrum/spectrum/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) and pick something you like! There is also [an "open" channel in the Spectrum community on Spectrum](https://spectrum.chat/spectrum/open) (how meta), if you run into troubles while trying to contribute that is the best place to talk to us.

Expand Down Expand Up @@ -162,12 +164,11 @@ Spectrum has four big installation steps:
1. **Install RethinkDB**: See [the RethinkDB documentation](https://rethinkdb.com/docs/install/) for instructions on installing it with your OS.
2. **Install Redis**: See [the Redis documentation](https://redis.io/download) for instructions on installing it with your OS.
3. **Install yarn**: We use [yarn](https://yarnpkg.com) to handle our JavaScript dependencies. (plain `npm` doesn't work due to our monorepo setup) See [the yarn documentation](https://yarnpkg.com/en/docs/install) for instructions on installing it.
4. **Install the dependencies**: Because it's pretty tedious to install the dependencies for each worker individually we've created a script that goes through and runs `yarn install` for every worker for you: (this takes a couple minutes, so dive into the [technical docs](./docs) in the meantime)

Once you have RethinkDB, Redis and yarn installed locally its time to install the JavaScript dependencies. Because it's pretty tedious to install the dependencies for each worker individually we've created a script that goes through and runs `yarn install` for every worker for you: (this takes a couple minutes, so dive into the [technical docs](./docs) in the meantime)

```sh
node shared/install-dependencies.js
```
```sh
node shared/install-dependencies.js
```

You've now finished installing everything! Let's migrate the database and you'll be ready to go :100:

Expand Down
11 changes: 8 additions & 3 deletions api/mutations/directMessageThread/createDirectMessageThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ import type { FileUpload } from 'shared/types';
import { events } from 'shared/analytics';
import { trackQueue } from 'shared/bull/queues';
import { isAuthedResolver as requireAuth } from '../../utils/permissions';
import { messageTypeObj } from 'shared/draft-utils/process-message-content';
import type { MessageType } from 'shared/draft-utils/process-message-content';

export type CreateDirectMessageThreadInput = {
input: {
participants: Array<string>,
message: {
messageType: 'text' | 'media' | 'draftjs',
messageType: MessageType,
threadType: string,
content: {
body: string,
Expand Down Expand Up @@ -80,15 +82,18 @@ export default requireAuth(
}

const handleStoreMessage = async message => {
if (message.messageType === 'text' || message.messageType === 'draftjs') {
if (
message.messageType === messageTypeObj.text ||
message.messageType === messageTypeObj.draftjs
) {
// once we have an id we can generate a proper message object
const messageWithThread = {
...message,
threadId,
};

return await storeMessage(messageWithThread, user.id);
} else if (message.messageType === 'media' && message.file) {
} else if (message.messageType === messageTypeObj.media && message.file) {
let url;
try {
url = await uploadImage(message.file, 'threads', threadId);
Expand Down
27 changes: 13 additions & 14 deletions api/mutations/message/addMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ import {
} from '../../utils/permissions';
import { trackQueue, calculateThreadScoreQueue } from 'shared/bull/queues';
import { validateRawContentState } from '../../utils/validate-draft-js-input';
import processMessageContent, {
messageTypeObj,
} from 'shared/draft-utils/process-message-content';
import type { MessageType } from 'shared/draft-utils/process-message-content';

type Input = {
message: {
threadId: string,
threadType: 'story' | 'directMessageThread',
messageType: 'text' | 'media' | 'draftjs',
messageType: MessageType,
content: {
body: string,
},
Expand All @@ -42,20 +46,15 @@ export const addMessage = async (
? events.MESSAGE_SENT_FAILED
: events.DIRECT_MESSAGE_SENT_FAILED;

if (message.messageType === 'text') {
message.content.body = JSON.stringify(
convertToRaw(
stateFromMarkdown(message.content.body, {
parserOptions: {
breaks: true,
},
})
)
if (message.messageType === messageTypeObj.text) {
message.content.body = processMessageContent(
messageTypeObj.text,
message.content.body
);
message.messageType = 'draftjs';
message.messageType = messageTypeObj.draftjs;
}

if (message.messageType === 'draftjs') {
if (message.messageType === messageTypeObj.draftjs) {
let body;
try {
body = JSON.parse(message.content.body);
Expand Down Expand Up @@ -107,7 +106,7 @@ export const addMessage = async (

// construct the shape of the object to be stored in the db
let messageForDb = Object.assign({}, message);
if (message.file && message.messageType === 'media') {
if (message.file && message.messageType === messageTypeObj.media) {
const { file } = message;

const fileMetaData = {
Expand Down Expand Up @@ -186,7 +185,7 @@ export default requireAuth(async (_: any, args: Input, ctx: GraphQLContext) => {
}
}

if (message.messageType === 'media' && !message.file) {
if (message.messageType === messageTypeObj.media && !message.file) {
trackQueue.add({
userId: user.id,
event: eventFailed,
Expand Down
23 changes: 9 additions & 14 deletions api/mutations/message/editMessage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @flow
import type { GraphQLContext } from '../../';
import { convertToRaw } from 'draft-js';
import { stateFromMarkdown } from 'draft-js-import-markdown';
import UserError from '../../utils/UserError';
import {
Expand All @@ -17,11 +16,15 @@ import { events } from 'shared/analytics';
import { isAuthedResolver as requireAuth } from '../../utils/permissions';
import { trackQueue } from 'shared/bull/queues';
import { validateRawContentState } from '../../utils/validate-draft-js-input';
import processMessageContent, {
messageTypeObj,
} from 'shared/draft-utils/process-message-content';
import type { MessageType } from 'shared/draft-utils/process-message-content';

type Args = {
input: {
id: string,
messageType?: 'draftjs' | 'text' | 'media',
messageType?: MessageType,
content: {
body: string,
},
Expand Down Expand Up @@ -49,24 +52,16 @@ export default requireAuth(async (_: any, args: Args, ctx: GraphQLContext) => {
}

let body = content.body;
if (messageType === 'text') {
body = JSON.stringify(
convertToRaw(
stateFromMarkdown(body, {
parserOptions: {
breaks: true,
},
})
)
);
messageType = 'draftjs';
if (messageType === messageTypeObj.text) {
body = processMessageContent(messageTypeObj.text, body);
messageType = messageTypeObj.draftjs;
}
const eventFailed =
message.threadType === 'story'
? events.MESSAGE_EDITED_FAILED
: events.DIRECT_MESSAGE_EDITED_FAILED;

if (messageType === 'draftjs') {
if (messageType === messageTypeObj.draftjs) {
let parsed;
try {
parsed = JSON.parse(body);
Expand Down
7 changes: 1 addition & 6 deletions api/mutations/thread/publishThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,10 @@ export default requireAuth(
// Post a new message with a link to the new thread to the watercooler thread if one exists
if (community.watercoolerId && !channel.isPrivate) {
const identifier = user.username ? `@${user.username}` : user.name;
const sentence =
Array.isArray(usersPreviousPublishedThreads) &&
usersPreviousPublishedThreads.length === 0
? `their first thread 👋`
: 'a new thread 📝';
await addMessage(
{
content: {
body: `${identifier} just posted ${sentence} https://spectrum.chat/${
body: `${identifier} just posted a new thread 📝 https://spectrum.chat/${
community.slug
}/${channel.slug}/${slugg(dbThread.content.title)}~${dbThread.id}`,
},
Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"pre-commit": "^1.2.2",
"prismjs": "^1.15.0",
"query-string": "5.1.1",
"ratelimiter": "^3.2.0",
"ratelimiter": "^3.3.0",
"raven": "^2.6.4",
"react": "^15.4.1",
"react-app-rewire-styled-components": "^3.0.2",
Expand Down
3 changes: 2 additions & 1 deletion api/queries/directMessageThread/snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import type { GraphQLContext } from '../../';
import { canViewDMThread } from '../../utils/permissions';
import { toPlainText, toState } from 'shared/draft-utils';
import { messageTypeObj } from 'shared/draft-utils/process-message-content';

export default async (
{ id }: { id: string },
Expand All @@ -17,7 +18,7 @@ export default async (
return loaders.directMessageSnippet.load(id).then(message => {
if (!message) return 'No messages yet...';
if (message.messageType === 'media') return '📷 Photo';
return message.messageType === 'draftjs'
return message.messageType === messageTypeObj.draftjs
? toPlainText(toState(JSON.parse(message.content.body)))
: message.content.body;
});
Expand Down
8 changes: 4 additions & 4 deletions api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7823,10 +7823,10 @@ range-parser@~1.2.0:
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e"
integrity sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=

ratelimiter@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/ratelimiter/-/ratelimiter-3.2.0.tgz#ae74cf9629daae4cc8900ec126ab28d3794070f1"
integrity sha512-zMc9X4FNmOk3RBxV95lvp13sZRtf43UJJN1FficbYiusBB09zB6gcJtK2X18dKmH+Gq0C7W6qNCHE+UJx0YwVg==
ratelimiter@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/ratelimiter/-/ratelimiter-3.3.0.tgz#bed9882f552e1aff4d7d3281bd1ab380f94cbf74"
integrity sha512-dDax7d0XosqzOrrQyMYEiu87tHDT6Wqm9LtGlxnQVAQJtEG6bmbvgPZ6E2/g1XrIpikJyec9hrOHKZ+DuVWxgQ==

raven@^2.6.4:
version "2.6.4"
Expand Down
3 changes: 2 additions & 1 deletion athena/queues/direct-message-notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { toPlainText, toState } from 'shared/draft-utils';
import { sendNewDirectMessageEmailQueue } from 'shared/bull/queues';
import type { Job, DirectMessageNotificationJobData } from 'shared/bull/types';
import { signUser, signMessage } from 'shared/imgix';
import { messageTypeObj } from 'shared/draft-utils/process-message-content';

export default async (job: Job<DirectMessageNotificationJobData>) => {
const { message: incomingMessage, userId: currentUserId } = job.data;
Expand Down Expand Up @@ -115,7 +116,7 @@ export default async (job: Job<DirectMessageNotificationJobData>) => {
...signedMessage,
content: {
body:
signedMessage.messageType === 'draftjs'
signedMessage.messageType === messageTypeObj.draftjs
? toPlainText(toState(JSON.parse(signedMessage.content.body)))
: signedMessage.content.body,
},
Expand Down
3 changes: 2 additions & 1 deletion athena/queues/moderationEvents/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { toState, toPlainText } from 'shared/draft-utils';
import getPerspectiveScore from './perspective';
import { _adminSendToxicContentEmailQueue } from 'shared/bull/queues';
import type { Job, AdminToxicMessageJobData } from 'shared/bull/types';
import { messageTypeObj } from 'shared/draft-utils/process-message-content';

export default async (job: Job<AdminToxicMessageJobData>) => {
debug('new job for admin message moderation');
Expand All @@ -16,7 +17,7 @@ export default async (job: Job<AdminToxicMessageJobData>) => {
} = job;

const text =
message.messageType === 'draftjs'
message.messageType === messageTypeObj.draftjs
? toPlainText(toState(JSON.parse(message.content.body)))
: message.content.body;

Expand Down
3 changes: 2 additions & 1 deletion athena/queues/new-message-in-thread/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { getMessageById } from '../../models/message';
import { sendMentionNotificationQueue } from 'shared/bull/queues';
import type { MessageNotificationJobData, Job } from 'shared/bull/types';
import type { DBMessage } from 'shared/types';
import { messageTypeObj } from 'shared/draft-utils/process-message-content';

export default async (job: Job<MessageNotificationJobData>) => {
const { message: incomingMessage } = job.data;
Expand Down Expand Up @@ -95,7 +96,7 @@ export default async (job: Job<MessageNotificationJobData>) => {

// convert the message body to be checked for mentions
const body =
incomingMessage.messageType === 'draftjs'
incomingMessage.messageType === messageTypeObj.draftjs
? toPlainText(toState(JSON.parse(incomingMessage.content.body)))
: incomingMessage.content.body;

Expand Down
1 change: 1 addition & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

// Import commands.js using ES2015 syntax:
import './commands';
require('cypress-plugin-retries');

before(() => {
cy.resetdb();
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Spectrum",
"version": "2.8.1",
"version": "2.8.2",
"license": "BSD-3-Clause",
"devDependencies": {
"@babel/preset-flow": "^7.0.0",
Expand All @@ -22,6 +22,7 @@
"cheerio": "^1.0.0-rc.2",
"cpy-cli": "^2.0.0",
"cross-env": "^5.2.0",
"cypress-plugin-retries": "^1.2.0",
"eslint": "^4.1.1",
"eslint-config-react-app": "^2.1.0",
"eslint-plugin-flowtype": "^2.50.3",
Expand Down Expand Up @@ -264,7 +265,7 @@
"jest": "cross-env NODE_PATH=./ jest",
"test": "npm run jest -- --runInBand --watch",
"test:ci": "npm run jest -- --forceExit --outputFile test-results.json --json --maxWorkers=2",
"test:e2e": "cypress run",
"test:e2e": "CYPRESS_RETRIES=2 cypress run",
"prestart:api:test": "node -e \"require('./shared/testing/setup.js')().then(() => process.exit())\"",
"start:api:test": "TEST_DB=true FORCE_DEV=true DEBUG=api*,shared* forever build-api/main.js",
"cypress:open": "cypress open",
Expand Down
Loading