Fixed Type Issues
This commit is contained in:
@@ -6,6 +6,7 @@ import { Attributes, where } from "@sequelize/core";
|
||||
import { cookies } from 'next/headers';
|
||||
import { getCookieAuth, userIsAdmin } from '../actions';
|
||||
import { ActionResult } from '../ActionResult';
|
||||
import { PostAttributesWithBuckets } from '@/model/Post';
|
||||
|
||||
|
||||
|
||||
@@ -20,13 +21,23 @@ export async function deletePost(postID: number): Promise<ActionResult<boolean>>
|
||||
}
|
||||
|
||||
|
||||
export async function getPosts(): Promise<ActionResult<Attributes<Post>[]>> {
|
||||
export async function getPostsWithBuckets(): Promise<ActionResult<PostAttributesWithBuckets[]>> {
|
||||
await dbSync;
|
||||
if(! await userIsAdmin()) return {error:"Unauthorized, not fetching Posts."}
|
||||
const posts = await Post.findAll({include: {association: Post.associations.buckets, include: Bucket.associations.attachments}},);
|
||||
return {result:JSON.parse(JSON.stringify(posts))};
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function getPosts(): Promise<ActionResult<Attributes<Post>[]>> {
|
||||
await dbSync;
|
||||
if(! await userIsAdmin()) return {error:"Unauthorized, not fetching Posts."}
|
||||
const posts = await Post.findAll();
|
||||
return {result:JSON.parse(JSON.stringify(posts))};
|
||||
}
|
||||
|
||||
|
||||
export async function updatePost(postAttributes: Partial<Attributes<Post>>): Promise<ActionResult<Attributes<Post>[]>> {
|
||||
await dbSync;
|
||||
if(! await userIsAdmin()) return {error:"Unauthorized, not updating Post."}
|
||||
|
||||
Reference in New Issue
Block a user