Fix for posts not found

This commit is contained in:
2023-11-28 22:54:39 +03:00
parent 743e073935
commit 318a40b961

View File

@@ -99,7 +99,7 @@ export class PostService {
async post() {
try {
const posts = await this.postRepository.find({ order: { timestamp: 'ASC' }, where: { posted: false }, relations: { images: true } });
if (!posts) throw new HttpException('Nothing to post', HttpStatus.NOT_FOUND);
if (!posts.length) throw new HttpException('Nothing to post', HttpStatus.NOT_FOUND);
const post = posts[0];
post.posted = true;
this.logger.log(`[post.post] Post ${post.uuid} is posted`);