This avoids having large file uploads going directly to the server and allows us to fetch it async into a worker process
15 lines
395 B
JavaScript
15 lines
395 B
JavaScript
// @flow
|
|
import { Attachment, User } from "../models";
|
|
import policy from "./policy";
|
|
|
|
const { allow } = policy;
|
|
|
|
allow(User, "create", Attachment);
|
|
|
|
allow(User, ["read", "delete"], Attachment, (actor, attachment) => {
|
|
if (!attachment || attachment.teamId !== actor.teamId) return false;
|
|
if (actor.isAdmin) return true;
|
|
if (actor.id === attachment.userId) return true;
|
|
return false;
|
|
});
|