Skip to content

Commit

Permalink
Merge pull request #614 from gitroomhq/feat/auto-post
Browse files Browse the repository at this point in the history
Add auto-posting from RSS
  • Loading branch information
nevo-david authored Feb 14, 2025
2 parents b4a8a13 + 4a787cc commit ac4c990
Show file tree
Hide file tree
Showing 19 changed files with 2,366 additions and 5,778 deletions.
2 changes: 2 additions & 0 deletions apps/backend/src/api/api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { ShortLinkService } from '@gitroom/nestjs-libraries/short-linking/short.
import { Nowpayments } from '@gitroom/nestjs-libraries/crypto/nowpayments';
import { WebhookController } from '@gitroom/backend/api/routes/webhooks.controller';
import { SignatureController } from '@gitroom/backend/api/routes/signature.controller';
import { AutopostController } from '@gitroom/backend/api/routes/autopost.controller';

const authenticatedController = [
UsersController,
Expand All @@ -46,6 +47,7 @@ const authenticatedController = [
AgenciesController,
WebhookController,
SignatureController,
AutopostController,
];
@Module({
imports: [UploadModule],
Expand Down
73 changes: 73 additions & 0 deletions apps/backend/src/api/routes/autopost.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import {
Body,
Controller,
Delete,
Get,
Param,
Post,
Put,
Query,
} from '@nestjs/common';
import { GetOrgFromRequest } from '@gitroom/nestjs-libraries/user/org.from.request';
import { Organization } from '@prisma/client';
import { ApiTags } from '@nestjs/swagger';
import { CheckPolicies } from '@gitroom/backend/services/auth/permissions/permissions.ability';
import {
AuthorizationActions,
Sections,
} from '@gitroom/backend/services/auth/permissions/permissions.service';
import { AutopostService } from '@gitroom/nestjs-libraries/database/prisma/autopost/autopost.service';
import { AutopostDto } from '@gitroom/nestjs-libraries/dtos/autopost/autopost.dto';
import { XMLParser, XMLBuilder, XMLValidator } from 'fast-xml-parser';
import dayjs from 'dayjs';

@ApiTags('Autopost')
@Controller('/autopost')
export class AutopostController {
constructor(private _autopostsService: AutopostService) {}

@Get('/')
async getAutoposts(@GetOrgFromRequest() org: Organization) {
return this._autopostsService.getAutoposts(org.id);
}

@Post('/')
@CheckPolicies([AuthorizationActions.Create, Sections.WEBHOOKS])
async createAutopost(
@GetOrgFromRequest() org: Organization,
@Body() body: AutopostDto
) {
return this._autopostsService.createAutopost(org.id, body);
}

@Put('/:id')
async updateAutopost(
@GetOrgFromRequest() org: Organization,
@Body() body: AutopostDto,
@Param('id') id: string
) {
return this._autopostsService.createAutopost(org.id, body, id);
}

@Delete('/:id')
async deleteAutopost(
@GetOrgFromRequest() org: Organization,
@Param('id') id: string
) {
return this._autopostsService.deleteAutopost(org.id, id);
}

@Post('/:id/active')
async changeActive(
@GetOrgFromRequest() org: Organization,
@Param('id') id: string,
@Body('active') active: boolean
) {
return this._autopostsService.changeActive(org.id, id, active);
}

@Post('/send')
async sendWebhook(@Query('url') url: string) {
return this._autopostsService.loadXML(url);
}
}
5 changes: 1 addition & 4 deletions apps/backend/src/api/routes/public.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ export class PublicController {
}

@Post('/crypto/:path')
async cryptoPost(
@Body() body: any,
@Param('path') path: string
) {
async cryptoPost(@Body() body: any, @Param('path') path: string) {
console.log('cryptoPost', body, path);
return this._nowpayments.processPayment(path, body);
}
Expand Down
Loading

0 comments on commit ac4c990

Please sign in to comment.