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

Commit

Permalink
Merge pull request #4627 from withspectrum/alpha
Browse files Browse the repository at this point in the history
v2.7.0
  • Loading branch information
mxstbr authored Feb 12, 2019
2 parents cec409d + b8d2798 commit 7f168b8
Show file tree
Hide file tree
Showing 57 changed files with 1,667 additions and 1,321 deletions.
2 changes: 1 addition & 1 deletion analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"dependencies": {
"amplitude": "^3.5.0",
"aws-sdk": "^2.383.0",
"aws-sdk": "^2.395.0",
"bull": "3.3.10",
"datadog-metrics": "^0.8.1",
"debug": "^4.1.1",
Expand Down
15 changes: 5 additions & 10 deletions analytics/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ asynckit@^0.4.0:
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=

aws-sdk@^2.383.0:
version "2.383.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.383.0.tgz#86045c0a4a4898dca84a4877cbe765b7dc0f8bba"
integrity sha512-PN+s+NTABtBloS46c7C2dvoEzrdY2NZ5nsfljL3xDX2rvjJEQxdchS2jcCpyc5ZNudFwta66wY4EGBZqf4Attw==
aws-sdk@^2.395.0:
version "2.395.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.395.0.tgz#637e5fa06d69bfb923b17bde24a8bd2a74dedab3"
integrity sha512-ldTTjctniZT4E2lq2z3D8Y2u+vpkp+laoEnDkXgjKXTKbiJ0QEtfWsUdx/IQ7awCt8stoxyqZK47DJOxIbRNoA==
dependencies:
buffer "4.9.1"
events "1.1.1"
Expand All @@ -26,7 +26,7 @@ aws-sdk@^2.383.0:
querystring "0.2.0"
sax "1.2.1"
url "0.10.3"
uuid "3.1.0"
uuid "3.3.2"
xml2js "0.4.19"

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

[email protected]:
version "3.1.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04"
integrity sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==

[email protected], uuid@^3.1.0:
version "3.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
Expand Down
8 changes: 8 additions & 0 deletions api/mutations/files/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @flow
import uploadImage from './uploadImage';

module.exports = {
Mutation: {
uploadImage,
},
};
23 changes: 23 additions & 0 deletions api/mutations/files/uploadImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @flow
import { isAuthedResolver } from '../../utils/permissions';
import { uploadImage } from '../../utils/file-storage';
import type { EntityTypes } from 'shared/types';
import type { GraphQLContext } from '../../';
import type { FileUpload } from 'shared/types';
import { signImageUrl } from 'shared/imgix';

type Args = {
input: {
image: FileUpload,
type: EntityTypes,
id?: string,
},
};

export default isAuthedResolver(
async (_: void, { input }: Args, { loaders }: GraphQLContext) => {
const { image, type, id } = input;
const url = await uploadImage(image, type, id || 'draft');
return await signImageUrl(url);
}
);
25 changes: 10 additions & 15 deletions api/mutations/thread/publishThread.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
// @flow
const debug = require('debug')('api:mutations:thread:publish-thread');
import stringSimilarity from 'string-similarity';
import { convertToRaw } from 'draft-js';
import {
convertToRaw,
convertFromRaw,
EditorState,
SelectionState,
} from 'draft-js';
import { stateFromMarkdown } from 'draft-js-import-markdown';
import type { GraphQLContext } from '../../';
import UserError from '../../utils/UserError';
import { uploadImage } from '../../utils/file-storage';
import processThreadContent from 'shared/draft-utils/process-thread-content';
import {
publishThread,
editThread,
Expand Down Expand Up @@ -68,22 +74,11 @@ export default requireAuth(
);
}

if (type === 'TEXT') {
type = 'DRAFTJS';
if (thread.content.body) {
thread.content.body = JSON.stringify(
convertToRaw(
stateFromMarkdown(thread.content.body, {
parserOptions: {
breaks: true,
},
})
)
);
}
if (thread.content.body) {
thread.content.body = processThreadContent(type, thread.content.body);
}

thread.type = type;
thread.type = 'DRAFTJS';

const [
currentUserChannelPermissions,
Expand Down
10 changes: 5 additions & 5 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"algoliasearch": "^3.32.0",
"apollo-local-query": "^0.3.1",
"apollo-server-express": "2.4.0-alpha.0",
"apollo-server-express": "^2.4.0",
"apollo-upload-client": "^9.1.0",
"aws-sdk": "2.200.0",
"axios": "^0.16.2",
Expand Down Expand Up @@ -35,7 +35,7 @@
"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-import-markdown": "^1.2.3",
"draft-js-import-markdown": "^1.3.1",
"draft-js-linkify-plugin": "^2.0.0-beta1",
"draft-js-markdown-plugin": "^1.4.4",
"draft-js-plugins-editor": "^2.1.1",
Expand All @@ -54,10 +54,10 @@
"graphql-date": "^1.0.3",
"graphql-depth-limit": "^1.1.0",
"graphql-log": "^0.1.3",
"graphql-rate-limit": "^1.2.2",
"graphql-rate-limit": "^1.2.3",
"graphql-tools": "^4.0.4",
"helmet": "^3.15.0",
"highlight.js": "^9.13.1",
"highlight.js": "^9.14.2",
"history": "^4.6.1",
"hoist-non-react-statics": "^2.5.5",
"host-validation": "^1.2.0",
Expand Down Expand Up @@ -121,7 +121,7 @@
"sanitize-filename": "^1.6.1",
"serialize-javascript": "^1.6.1",
"session-rethinkdb": "^2.0.0",
"slate": "^0.44.9",
"slate": "^0.44.10",
"slate-markdown": "0.1.0",
"slugg": "^1.1.0",
"string-replace-to-array": "^1.0.3",
Expand Down
2 changes: 2 additions & 0 deletions api/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const notificationMutations = require('./mutations/notification');
const userMutations = require('./mutations/user');
const metaMutations = require('./mutations/meta');
const communityMemberMutations = require('./mutations/communityMember');
const fileMutations = require('./mutations/files');

const messageSubscriptions = require('./subscriptions/message');
const notificationSubscriptions = require('./subscriptions/notification');
Expand Down Expand Up @@ -125,6 +126,7 @@ const resolvers = merge(
userMutations,
metaMutations,
communityMemberMutations,
fileMutations,
// subscriptions
messageSubscriptions,
notificationSubscriptions,
Expand Down
18 changes: 18 additions & 0 deletions api/types/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ const general = /* GraphQL */ `
createdAt: String
status: String
}
enum EntityTypes {
communities
channels
users
threads
}
input UploadImageInput {
image: Upload!
type: EntityTypes!
id: String
}
extend type Mutation {
uploadImage(input: UploadImageInput!): String
@rateLimit(max: 20, window: "20m")
}
`;

module.exports = general;
Loading

0 comments on commit 7f168b8

Please sign in to comment.