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

Commit 7f168b8

Browse files
authored
Merge pull request #4627 from withspectrum/alpha
v2.7.0
2 parents cec409d + b8d2798 commit 7f168b8

File tree

57 files changed

+1667
-1321
lines changed

Some content is hidden

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

57 files changed

+1667
-1321
lines changed

analytics/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"dependencies": {
88
"amplitude": "^3.5.0",
9-
"aws-sdk": "^2.383.0",
9+
"aws-sdk": "^2.395.0",
1010
"bull": "3.3.10",
1111
"datadog-metrics": "^0.8.1",
1212
"debug": "^4.1.1",

analytics/yarn.lock

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ asynckit@^0.4.0:
1414
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
1515
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=
1616

17-
aws-sdk@^2.383.0:
18-
version "2.383.0"
19-
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.383.0.tgz#86045c0a4a4898dca84a4877cbe765b7dc0f8bba"
20-
integrity sha512-PN+s+NTABtBloS46c7C2dvoEzrdY2NZ5nsfljL3xDX2rvjJEQxdchS2jcCpyc5ZNudFwta66wY4EGBZqf4Attw==
17+
aws-sdk@^2.395.0:
18+
version "2.395.0"
19+
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.395.0.tgz#637e5fa06d69bfb923b17bde24a8bd2a74dedab3"
20+
integrity sha512-ldTTjctniZT4E2lq2z3D8Y2u+vpkp+laoEnDkXgjKXTKbiJ0QEtfWsUdx/IQ7awCt8stoxyqZK47DJOxIbRNoA==
2121
dependencies:
2222
buffer "4.9.1"
2323
events "1.1.1"
@@ -26,7 +26,7 @@ aws-sdk@^2.383.0:
2626
querystring "0.2.0"
2727
sax "1.2.1"
2828
url "0.10.3"
29-
uuid "3.1.0"
29+
uuid "3.3.2"
3030
xml2js "0.4.19"
3131

3232
base64-js@^1.0.2:
@@ -713,11 +713,6 @@ util-deprecate@~1.0.1:
713713
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
714714
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
715715

716-
717-
version "3.1.0"
718-
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04"
719-
integrity sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==
720-
721716
[email protected], uuid@^3.1.0:
722717
version "3.3.2"
723718
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"

api/mutations/files/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @flow
2+
import uploadImage from './uploadImage';
3+
4+
module.exports = {
5+
Mutation: {
6+
uploadImage,
7+
},
8+
};

api/mutations/files/uploadImage.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// @flow
2+
import { isAuthedResolver } from '../../utils/permissions';
3+
import { uploadImage } from '../../utils/file-storage';
4+
import type { EntityTypes } from 'shared/types';
5+
import type { GraphQLContext } from '../../';
6+
import type { FileUpload } from 'shared/types';
7+
import { signImageUrl } from 'shared/imgix';
8+
9+
type Args = {
10+
input: {
11+
image: FileUpload,
12+
type: EntityTypes,
13+
id?: string,
14+
},
15+
};
16+
17+
export default isAuthedResolver(
18+
async (_: void, { input }: Args, { loaders }: GraphQLContext) => {
19+
const { image, type, id } = input;
20+
const url = await uploadImage(image, type, id || 'draft');
21+
return await signImageUrl(url);
22+
}
23+
);

api/mutations/thread/publishThread.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
// @flow
22
const debug = require('debug')('api:mutations:thread:publish-thread');
33
import stringSimilarity from 'string-similarity';
4-
import { convertToRaw } from 'draft-js';
4+
import {
5+
convertToRaw,
6+
convertFromRaw,
7+
EditorState,
8+
SelectionState,
9+
} from 'draft-js';
510
import { stateFromMarkdown } from 'draft-js-import-markdown';
611
import type { GraphQLContext } from '../../';
712
import UserError from '../../utils/UserError';
813
import { uploadImage } from '../../utils/file-storage';
14+
import processThreadContent from 'shared/draft-utils/process-thread-content';
915
import {
1016
publishThread,
1117
editThread,
@@ -68,22 +74,11 @@ export default requireAuth(
6874
);
6975
}
7076

71-
if (type === 'TEXT') {
72-
type = 'DRAFTJS';
73-
if (thread.content.body) {
74-
thread.content.body = JSON.stringify(
75-
convertToRaw(
76-
stateFromMarkdown(thread.content.body, {
77-
parserOptions: {
78-
breaks: true,
79-
},
80-
})
81-
)
82-
);
83-
}
77+
if (thread.content.body) {
78+
thread.content.body = processThreadContent(type, thread.content.body);
8479
}
8580

86-
thread.type = type;
81+
thread.type = 'DRAFTJS';
8782

8883
const [
8984
currentUserChannelPermissions,

api/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"dependencies": {
66
"algoliasearch": "^3.32.0",
77
"apollo-local-query": "^0.3.1",
8-
"apollo-server-express": "2.4.0-alpha.0",
8+
"apollo-server-express": "^2.4.0",
99
"apollo-upload-client": "^9.1.0",
1010
"aws-sdk": "2.200.0",
1111
"axios": "^0.16.2",
@@ -35,7 +35,7 @@
3535
"draft-js-embed-plugin": "^1.2.0",
3636
"draft-js-focus-plugin": "2.0.0-rc2",
3737
"draft-js-image-plugin": "2.0.0-rc8",
38-
"draft-js-import-markdown": "^1.2.3",
38+
"draft-js-import-markdown": "^1.3.1",
3939
"draft-js-linkify-plugin": "^2.0.0-beta1",
4040
"draft-js-markdown-plugin": "^1.4.4",
4141
"draft-js-plugins-editor": "^2.1.1",
@@ -54,10 +54,10 @@
5454
"graphql-date": "^1.0.3",
5555
"graphql-depth-limit": "^1.1.0",
5656
"graphql-log": "^0.1.3",
57-
"graphql-rate-limit": "^1.2.2",
57+
"graphql-rate-limit": "^1.2.3",
5858
"graphql-tools": "^4.0.4",
5959
"helmet": "^3.15.0",
60-
"highlight.js": "^9.13.1",
60+
"highlight.js": "^9.14.2",
6161
"history": "^4.6.1",
6262
"hoist-non-react-statics": "^2.5.5",
6363
"host-validation": "^1.2.0",
@@ -121,7 +121,7 @@
121121
"sanitize-filename": "^1.6.1",
122122
"serialize-javascript": "^1.6.1",
123123
"session-rethinkdb": "^2.0.0",
124-
"slate": "^0.44.9",
124+
"slate": "^0.44.10",
125125
"slate-markdown": "0.1.0",
126126
"slugg": "^1.1.0",
127127
"string-replace-to-array": "^1.0.3",

api/schema.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const notificationMutations = require('./mutations/notification');
5656
const userMutations = require('./mutations/user');
5757
const metaMutations = require('./mutations/meta');
5858
const communityMemberMutations = require('./mutations/communityMember');
59+
const fileMutations = require('./mutations/files');
5960

6061
const messageSubscriptions = require('./subscriptions/message');
6162
const notificationSubscriptions = require('./subscriptions/notification');
@@ -125,6 +126,7 @@ const resolvers = merge(
125126
userMutations,
126127
metaMutations,
127128
communityMemberMutations,
129+
fileMutations,
128130
// subscriptions
129131
messageSubscriptions,
130132
notificationSubscriptions,

api/types/general.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ const general = /* GraphQL */ `
7676
createdAt: String
7777
status: String
7878
}
79+
80+
enum EntityTypes {
81+
communities
82+
channels
83+
users
84+
threads
85+
}
86+
87+
input UploadImageInput {
88+
image: Upload!
89+
type: EntityTypes!
90+
id: String
91+
}
92+
93+
extend type Mutation {
94+
uploadImage(input: UploadImageInput!): String
95+
@rateLimit(max: 20, window: "20m")
96+
}
7997
`;
8098

8199
module.exports = general;

0 commit comments

Comments
 (0)