chore: Move to prettier standard double quotes (#1309)

This commit is contained in:
Tom Moor
2020-06-20 13:59:15 -07:00
committed by GitHub
parent 2a3b9e2104
commit f43deb7940
444 changed files with 5988 additions and 5977 deletions

View File

@ -1,26 +1,26 @@
// @flow
import Router from 'koa-router';
import auth from '../middlewares/authentication';
import pagination from './middlewares/pagination';
import { Op } from '../sequelize';
import { MAX_AVATAR_DISPLAY } from '../../shared/constants';
import Router from "koa-router";
import auth from "../middlewares/authentication";
import pagination from "./middlewares/pagination";
import { Op } from "../sequelize";
import { MAX_AVATAR_DISPLAY } from "../../shared/constants";
import {
presentGroup,
presentPolicies,
presentUser,
presentGroupMembership,
} from '../presenters';
import { User, Event, Group, GroupUser } from '../models';
import policy from '../policies';
} from "../presenters";
import { User, Event, Group, GroupUser } from "../models";
import policy from "../policies";
const { authorize } = policy;
const router = new Router();
router.post('groups.list', auth(), pagination(), async ctx => {
const { sort = 'updatedAt' } = ctx.body;
router.post("groups.list", auth(), pagination(), async ctx => {
const { sort = "updatedAt" } = ctx.body;
let direction = ctx.body.direction;
if (direction !== 'ASC') direction = 'DESC';
if (direction !== "ASC") direction = "DESC";
const user = ctx.state.user;
let groups = await Group.findAll({
@ -55,13 +55,13 @@ router.post('groups.list', auth(), pagination(), async ctx => {
};
});
router.post('groups.info', auth(), async ctx => {
router.post("groups.info", auth(), async ctx => {
const { id } = ctx.body;
ctx.assertUuid(id, 'id is required');
ctx.assertUuid(id, "id is required");
const user = ctx.state.user;
const group = await Group.findByPk(id);
authorize(user, 'read', group);
authorize(user, "read", group);
ctx.body = {
data: presentGroup(group),
@ -69,13 +69,13 @@ router.post('groups.info', auth(), async ctx => {
};
});
router.post('groups.create', auth(), async ctx => {
router.post("groups.create", auth(), async ctx => {
const { name } = ctx.body;
ctx.assertPresent(name, 'name is required');
ctx.assertPresent(name, "name is required");
const user = ctx.state.user;
authorize(user, 'create', Group);
authorize(user, "create", Group);
let group = await Group.create({
name,
teamId: user.teamId,
@ -86,7 +86,7 @@ router.post('groups.create', auth(), async ctx => {
group = await Group.findByPk(group.id);
await Event.create({
name: 'groups.create',
name: "groups.create",
actorId: user.id,
teamId: user.teamId,
modelId: group.id,
@ -100,22 +100,22 @@ router.post('groups.create', auth(), async ctx => {
};
});
router.post('groups.update', auth(), async ctx => {
router.post("groups.update", auth(), async ctx => {
const { id, name } = ctx.body;
ctx.assertPresent(name, 'name is required');
ctx.assertUuid(id, 'id is required');
ctx.assertPresent(name, "name is required");
ctx.assertUuid(id, "id is required");
const user = ctx.state.user;
const group = await Group.findByPk(id);
authorize(user, 'update', group);
authorize(user, "update", group);
group.name = name;
if (group.changed()) {
await group.save();
await Event.create({
name: 'groups.update',
name: "groups.update",
teamId: user.teamId,
actorId: user.id,
modelId: group.id,
@ -130,18 +130,18 @@ router.post('groups.update', auth(), async ctx => {
};
});
router.post('groups.delete', auth(), async ctx => {
router.post("groups.delete", auth(), async ctx => {
const { id } = ctx.body;
ctx.assertUuid(id, 'id is required');
ctx.assertUuid(id, "id is required");
const { user } = ctx.state;
const group = await Group.findByPk(id);
authorize(user, 'delete', group);
authorize(user, "delete", group);
await group.destroy();
await Event.create({
name: 'groups.delete',
name: "groups.delete",
actorId: user.id,
modelId: group.id,
teamId: group.teamId,
@ -154,13 +154,13 @@ router.post('groups.delete', auth(), async ctx => {
};
});
router.post('groups.memberships', auth(), pagination(), async ctx => {
router.post("groups.memberships", auth(), pagination(), async ctx => {
const { id, query } = ctx.body;
ctx.assertUuid(id, 'id is required');
ctx.assertUuid(id, "id is required");
const user = ctx.state.user;
const group = await Group.findByPk(id);
authorize(user, 'read', group);
authorize(user, "read", group);
let userWhere;
if (query) {
@ -173,13 +173,13 @@ router.post('groups.memberships', auth(), pagination(), async ctx => {
const memberships = await GroupUser.findAll({
where: { groupId: id },
order: [['createdAt', 'DESC']],
order: [["createdAt", "DESC"]],
offset: ctx.state.pagination.offset,
limit: ctx.state.pagination.limit,
include: [
{
model: User,
as: 'user',
as: "user",
where: userWhere,
required: true,
},
@ -195,16 +195,16 @@ router.post('groups.memberships', auth(), pagination(), async ctx => {
};
});
router.post('groups.add_user', auth(), async ctx => {
router.post("groups.add_user", auth(), async ctx => {
const { id, userId } = ctx.body;
ctx.assertUuid(id, 'id is required');
ctx.assertUuid(userId, 'userId is required');
ctx.assertUuid(id, "id is required");
ctx.assertUuid(userId, "userId is required");
const user = await User.findByPk(userId);
authorize(ctx.state.user, 'read', user);
authorize(ctx.state.user, "read", user);
let group = await Group.findByPk(id);
authorize(ctx.state.user, 'update', group);
authorize(ctx.state.user, "update", group);
let membership = await GroupUser.findOne({
where: {
@ -230,7 +230,7 @@ router.post('groups.add_user', auth(), async ctx => {
group = await Group.findByPk(id);
await Event.create({
name: 'groups.add_user',
name: "groups.add_user",
userId,
teamId: user.teamId,
modelId: group.id,
@ -249,21 +249,21 @@ router.post('groups.add_user', auth(), async ctx => {
};
});
router.post('groups.remove_user', auth(), async ctx => {
router.post("groups.remove_user", auth(), async ctx => {
const { id, userId } = ctx.body;
ctx.assertUuid(id, 'id is required');
ctx.assertUuid(userId, 'userId is required');
ctx.assertUuid(id, "id is required");
ctx.assertUuid(userId, "userId is required");
let group = await Group.findByPk(id);
authorize(ctx.state.user, 'update', group);
authorize(ctx.state.user, "update", group);
const user = await User.findByPk(userId);
authorize(ctx.state.user, 'read', user);
authorize(ctx.state.user, "read", user);
await group.removeUser(user);
await Event.create({
name: 'groups.remove_user',
name: "groups.remove_user",
userId,
modelId: group.id,
teamId: user.teamId,