Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto-posting from RSS #614

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';

Check warning

Code scanning / ESLint

Disallow unused variables Warning

'XMLParser' is defined but never used.

Copilot Autofix AI 11 days ago

To fix the problem, we need to remove the unused XMLParser import from the file. This will resolve the ESLint error and clean up the code. The best way to fix this is to simply delete the XMLParser import statement from the import block at the top of the file.

Suggested changeset 1
apps/backend/src/api/routes/autopost.controller.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/backend/src/api/routes/autopost.controller.ts b/apps/backend/src/api/routes/autopost.controller.ts
--- a/apps/backend/src/api/routes/autopost.controller.ts
+++ b/apps/backend/src/api/routes/autopost.controller.ts
@@ -20,3 +20,3 @@
 import { AutopostDto } from '@gitroom/nestjs-libraries/dtos/autopost/autopost.dto';
-import { XMLParser, XMLBuilder, XMLValidator } from 'fast-xml-parser';
+import { XMLBuilder, XMLValidator } from 'fast-xml-parser';
 import dayjs from 'dayjs';
EOF
@@ -20,3 +20,3 @@
import { AutopostDto } from '@gitroom/nestjs-libraries/dtos/autopost/autopost.dto';
import { XMLParser, XMLBuilder, XMLValidator } from 'fast-xml-parser';
import { XMLBuilder, XMLValidator } from 'fast-xml-parser';
import dayjs from 'dayjs';
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options

Check warning

Code scanning / ESLint

Disallow unused variables Warning

'XMLBuilder' is defined but never used.

Copilot Autofix AI 11 days ago

To fix the problem, we need to remove the unused XMLBuilder import from the file. This will resolve the ESLint error and clean up the code. The change should be made in the apps/backend/src/api/routes/autopost.controller.ts file, specifically on line 21 where the XMLBuilder is imported.

Suggested changeset 1
apps/backend/src/api/routes/autopost.controller.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/backend/src/api/routes/autopost.controller.ts b/apps/backend/src/api/routes/autopost.controller.ts
--- a/apps/backend/src/api/routes/autopost.controller.ts
+++ b/apps/backend/src/api/routes/autopost.controller.ts
@@ -20,3 +20,3 @@
 import { AutopostDto } from '@gitroom/nestjs-libraries/dtos/autopost/autopost.dto';
-import { XMLParser, XMLBuilder, XMLValidator } from 'fast-xml-parser';
+import { XMLParser, XMLValidator } from 'fast-xml-parser';
 import dayjs from 'dayjs';
EOF
@@ -20,3 +20,3 @@
import { AutopostDto } from '@gitroom/nestjs-libraries/dtos/autopost/autopost.dto';
import { XMLParser, XMLBuilder, XMLValidator } from 'fast-xml-parser';
import { XMLParser, XMLValidator } from 'fast-xml-parser';
import dayjs from 'dayjs';
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options

Check warning

Code scanning / ESLint

Disallow unused variables Warning

'XMLValidator' is defined but never used.

Copilot Autofix AI 11 days ago

To fix the problem, we need to remove the unused import XMLValidator from the import statement on line 21. This will resolve the ESLint error and clean up the code by removing unnecessary imports.

  • Locate the import statement on line 21 in the file apps/backend/src/api/routes/autopost.controller.ts.
  • Remove XMLValidator from the import statement.
Suggested changeset 1
apps/backend/src/api/routes/autopost.controller.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/backend/src/api/routes/autopost.controller.ts b/apps/backend/src/api/routes/autopost.controller.ts
--- a/apps/backend/src/api/routes/autopost.controller.ts
+++ b/apps/backend/src/api/routes/autopost.controller.ts
@@ -20,3 +20,3 @@
 import { AutopostDto } from '@gitroom/nestjs-libraries/dtos/autopost/autopost.dto';
-import { XMLParser, XMLBuilder, XMLValidator } from 'fast-xml-parser';
+import { XMLParser, XMLBuilder } from 'fast-xml-parser';
 import dayjs from 'dayjs';
EOF
@@ -20,3 +20,3 @@
import { AutopostDto } from '@gitroom/nestjs-libraries/dtos/autopost/autopost.dto';
import { XMLParser, XMLBuilder, XMLValidator } from 'fast-xml-parser';
import { XMLParser, XMLBuilder } from 'fast-xml-parser';
import dayjs from 'dayjs';
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
import dayjs from 'dayjs';

Check warning

Code scanning / ESLint

Disallow unused variables Warning

'dayjs' is defined but never used.

Copilot Autofix AI 11 days ago

To fix the problem, we need to remove the unused dayjs import from the file. This will resolve the ESLint error and clean up the code. The change should be made in the file apps/backend/src/api/routes/autopost.controller.ts on line 22. No additional methods, imports, or definitions are needed to implement this change.

Suggested changeset 1
apps/backend/src/api/routes/autopost.controller.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/backend/src/api/routes/autopost.controller.ts b/apps/backend/src/api/routes/autopost.controller.ts
--- a/apps/backend/src/api/routes/autopost.controller.ts
+++ b/apps/backend/src/api/routes/autopost.controller.ts
@@ -21,3 +21,2 @@
 import { XMLParser, XMLBuilder, XMLValidator } from 'fast-xml-parser';
-import dayjs from 'dayjs';
 
EOF
@@ -21,3 +21,2 @@
import { XMLParser, XMLBuilder, XMLValidator } from 'fast-xml-parser';
import dayjs from 'dayjs';

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you comment a spam comment on this repository again, you will be banned from contributing to this Repository. @Azadbangladeshi-com


@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
Loading