|
|
@ -144,9 +144,13 @@ export function resolver(req: any, res: any): any {
|
|
|
|
async createPost({content}: { content: string }) {
|
|
|
|
async createPost({content}: { content: string }) {
|
|
|
|
if (content) {
|
|
|
|
if (content) {
|
|
|
|
if (req.session.userId) {
|
|
|
|
if (req.session.userId) {
|
|
|
|
const post = await dataaccess.createPost(content, req.session.userId);
|
|
|
|
if (content.length > 2048) {
|
|
|
|
globals.internalEmitter.emit(InternalEvents.GQLPOSTCREATE, post);
|
|
|
|
return new GraphQLError("Content too long.");
|
|
|
|
return post;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const post = await dataaccess.createPost(content, req.session.userId);
|
|
|
|
|
|
|
|
globals.internalEmitter.emit(InternalEvents.GQLPOSTCREATE, post);
|
|
|
|
|
|
|
|
return post;
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
res.status(status.UNAUTHORIZED);
|
|
|
|
res.status(status.UNAUTHORIZED);
|
|
|
|
return new NotLoggedInGqlError();
|
|
|
|
return new NotLoggedInGqlError();
|
|
|
|