-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #614 from gitroomhq/feat/auto-post
Add auto-posting from RSS
- Loading branch information
Showing
19 changed files
with
2,366 additions
and
5,778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.