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

Add auto-posting from RSS #614

merged 2 commits into from
Feb 14, 2025

Conversation

nevo-david
Copy link
Contributor

@nevo-david nevo-david commented Feb 14, 2025

  • feat: auto posts
  • fix: package json

Summary by CodeRabbit

  • New Features
    • Introduced autopost management capabilities that let eligible users create, update, delete, and toggle autopost webhooks.
    • Added a dedicated “Auto Post” tab in the settings panel for users with premium subscription tiers.
    • Enhanced backend scheduling and automation for autopost operations, improving overall performance and reliability.

Copy link

vercel bot commented Feb 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
gitroom ⬜️ Ignored (Inspect) Feb 14, 2025 9:39am
postiz ⬜️ Ignored (Inspect) Feb 14, 2025 9:39am

Copy link

coderabbitai bot commented Feb 14, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request implements a comprehensive autoposting feature across the application. It introduces a new AutopostController with endpoints for managing autoposts, integrates corresponding service and repository layers for business logic and database operations, and adds new DTOs and validations. The frontend is updated with new React components and a settings tab for autopost management. Additionally, worker modules and BullMQ client logic are modified to support scheduled autopost tasks, with minor adjustments in related controllers, pricing, and dependency updates.

Changes

File(s) Change Summary
apps/backend/src/api/api.module.ts
apps/backend/src/api/routes/autopost.controller.ts
Added AutopostController to the API module with endpoints for creating, updating, deleting, toggling active status, and sending webhooks.
apps/backend/src/api/routes/public.controller.ts Updated the cryptoPost method signature by removing an unnecessary line break (formatting change only).
apps/frontend/src/components/autopost/autopost.tsx
apps/frontend/src/components/layout/settings.component.tsx
Introduced new React components (Autopost and AddOrEditWebhook) and integrated an "Auto Post" tab into the settings panel.
apps/workers/src/app/posts.controller.ts Injected AutopostService and added a new cron event handler to trigger autopost scheduling.
libraries/nestjs-libraries/src/bull-mq-transport-new/client.ts Added deleteScheduler method and modified dispatchEvent to handle cron job options for scheduled tasks.
libraries/nestjs-libraries/src/database/prisma/autopost/autopost.repository.ts Introduced AutopostRepository for managing autopost CRUD operations with Prisma.
libraries/nestjs-libraries/src/database/prisma/autopost/autopost.service.ts Added AutopostService with methods for creating, deleting, updating, scheduling, and managing autopost workflows (including content and image generation).
libraries/nestjs-libraries/src/database/prisma/database.module.ts Updated module providers by adding AutopostRepository and AutopostService.
libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts
libraries/nestjs-libraries/src/database/prisma/organizations/organization.service.ts
Injected autopost-related dependencies and added changeActiveCron in the integration service for scheduler management.
libraries/nestjs-libraries/src/database/prisma/schema.prisma Added a new AutoPost model with related fields and updated the Organization model to include a relation to autoposts.
libraries/nestjs-libraries/src/database/prisma/subscriptions/pricing.ts
libraries/nestjs-libraries/src/database/prisma/subscriptions/subscription.service.ts
Introduced an autoPost property in pricing tiers and modified the subscription service to handle free tier logic via autopost scheduler removal.
libraries/nestjs-libraries/src/dtos/autopost/autopost.dto.ts Added new DTO classes (Integrations and AutopostDto) for request validation and data transfer of autopost entities.
libraries/nestjs-libraries/src/services/stripe.service.ts Removed unused OrderItems import for a slight dependency cleanup.
package.json Updated versions of several Copilotkit packages, added new dependencies (@types/striptags and fast-xml-parser), and refreshed the striptags version.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Frontend as "Autopost UI"
  participant Controller as "AutopostController"
  participant Service as "AutopostService"
  participant Repository as "AutopostRepository"
  participant External as "External API(s)"

  User->>Frontend: Interact with autopost tab
  Frontend->>Controller: Send autopost management request
  Controller->>Service: Call corresponding endpoint (create/update/delete)
  Service->>Repository: Persist or update autopost data
  Service-->>External: (Optional) Call for content/image generation
  Repository-->>Service: Return database response
  Service-->>Controller: Return service response
  Controller-->>Frontend: Respond with result
Loading
sequenceDiagram
  participant Worker as "PostsController (Worker)"
  participant Service as "AutopostService"
  participant Scheduler as "BullMQ Client"
  
  Worker->>Service: Trigger cron event (startAutopost)
  Service->>Scheduler: Schedule or remove a job via cron options
  Scheduler-->>Service: Job scheduled/removed confirmation
  Service-->>Worker: Return cron handling result
Loading

Possibly related PRs

  • Webhook #591: Adds the WebhookController to the API module, paralleling the current addition of the AutopostController by integrating controller functionality into the authentication flow.

Poem

I'm a little rabbit, hopping with cheer,
New autopost features are finally here!
Controllers and services dance in the night,
Frontend and backend now shine so bright.
Hop along the code, let each change inspire,
With each new line, my whiskers feel fire!
🐇💻✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b4a8a13 and 4a787cc.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (18)
  • apps/backend/src/api/api.module.ts (2 hunks)
  • apps/backend/src/api/routes/autopost.controller.ts (1 hunks)
  • apps/backend/src/api/routes/public.controller.ts (1 hunks)
  • apps/frontend/src/components/autopost/autopost.tsx (1 hunks)
  • apps/frontend/src/components/layout/settings.component.tsx (3 hunks)
  • apps/workers/src/app/posts.controller.ts (2 hunks)
  • libraries/nestjs-libraries/src/bull-mq-transport-new/client.ts (2 hunks)
  • libraries/nestjs-libraries/src/database/prisma/autopost/autopost.repository.ts (1 hunks)
  • libraries/nestjs-libraries/src/database/prisma/autopost/autopost.service.ts (1 hunks)
  • libraries/nestjs-libraries/src/database/prisma/database.module.ts (2 hunks)
  • libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts (2 hunks)
  • libraries/nestjs-libraries/src/database/prisma/organizations/organization.service.ts (1 hunks)
  • libraries/nestjs-libraries/src/database/prisma/schema.prisma (2 hunks)
  • libraries/nestjs-libraries/src/database/prisma/subscriptions/pricing.ts (6 hunks)
  • libraries/nestjs-libraries/src/database/prisma/subscriptions/subscription.service.ts (2 hunks)
  • libraries/nestjs-libraries/src/dtos/autopost/autopost.dto.ts (1 hunks)
  • libraries/nestjs-libraries/src/services/stripe.service.ts (1 hunks)
  • package.json (4 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nevo-david nevo-david merged commit ac4c990 into main Feb 14, 2025
8 of 9 checks passed
} 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 6 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
} 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

'XMLBuilder' is defined but never used.

Copilot Autofix AI 6 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
} 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

'XMLValidator' is defined but never used.

Copilot Autofix AI 6 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 { 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';

Check warning

Code scanning / ESLint

Disallow unused variables Warning

'dayjs' is defined but never used.

Copilot Autofix AI 6 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

@gitroomhq gitroomhq deleted a comment from Azadbangladeshi-com Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants