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

Plugs #479

Merged
merged 4 commits into from
Dec 9, 2024
Merged

Plugs #479

merged 4 commits into from
Dec 9, 2024

Conversation

nevo-david
Copy link
Contributor

@nevo-david nevo-david commented Dec 9, 2024

  • Feat: plugs
  • feat: plugs
  • feat: finalized plugs

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new Plugs management interface in the app.
    • Added methods for retrieving and managing plugs by integration.
    • New automated actions for reposting and promoting posts based on engagement metrics in various social providers.
  • Bug Fixes

    • Enhanced error handling in authentication and API interactions across providers.
  • Documentation

    • Updated documentation to reflect new plug functionalities and integrations.
  • Chores

    • Refactored code for improved readability and consistency across various modules.

Copy link

vercel bot commented Dec 9, 2024

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

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
gitroom ⬜️ Ignored (Inspect) Visit Preview Dec 9, 2024 9:43am
postiz ⬜️ Ignored (Inspect) Visit Preview Dec 9, 2024 9:43am

Copy link

coderabbitai bot commented Dec 9, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes introduce significant enhancements across multiple files, primarily focusing on the management and functionality of "plugs" within the application. New methods are added to controllers and services, enabling operations like retrieving, creating, updating, and activating plugs. Additionally, new React components and context for plugs are created in the frontend, while the backend sees the introduction of new models and decorators. The modifications enhance the integration capabilities and improve user interactions with the plug management system.

Changes

File Change Summary
apps/backend/src/api/routes/integrations.controller.ts Added methods: getPlugList, getPlugsByIntegrationId, postPlugsByIntegrationId, changePlugActivation. Updated imports to include PlugDto.
apps/frontend/src/app/(site)/plugs/page.tsx Introduced a new React component for rendering the Plugs page, with dynamic export and metadata settings.
apps/frontend/src/components/layout/top.menu.tsx Modified useMenuItems to remove "Marketplace" and "Messages", added "Plugs".
apps/frontend/src/components/plugs/plug.tsx Introduced components: Plug, PlugItem, PlugPop, TextArea, and function convertBackRegex.
apps/frontend/src/components/plugs/plugs.context.ts Added interfaces: PlugSettings, PlugInterface, FieldsInterface, PlugsInterface. Created context PlugsContext and hook usePlugs.
apps/frontend/src/components/plugs/plugs.tsx Introduced a new component Plugs for managing and displaying integrations.
apps/workers/src/app/app.module.ts Added PlugsController to the module.
apps/workers/src/app/plugs.controller.ts Created PlugsController with a method plug for handling Redis events.
apps/workers/src/app/posts.controller.ts Updated payout method's parameter type declaration from comma to semicolon.
libraries/helpers/src/decorators/plug.decorator.ts Introduced a new decorator function Plug for managing plug metadata.
libraries/nestjs-libraries/src/bull-mq-transport-new/client.ts Modified job management logic in publishAsync and dispatchEvent methods regarding job removal conditions.
libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts Added methods for plug management: getPlug, getPlugs, getPlugsByIntegrationId, createOrUpdatePlug, changePlugActivation, loadExisingData, saveExisingData. Added private properties _plugs, _exisingPlugData.
libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts Added methods for plug operations: getPlugsByIntegrationId, processPlugs, createOrUpdatePlug, changePlugActivation, getPlugs, loadExisingData. Updated constructor to include _workerServiceProducer.
libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts Added private method checkPlugs to manage integration plugs after post publication.
libraries/nestjs-libraries/src/database/prisma/schema.prisma Added new models Plugs, ExisingPlugData and new fields in Organization and Integration models.
libraries/nestjs-libraries/src/dtos/plugs/plug.dto.ts Introduced DTO classes: FieldsDto and PlugDto for plug data validation.
libraries/nestjs-libraries/src/integrations/integration.manager.ts Added method getAllPlugs to retrieve detailed plug information for social integrations.
libraries/nestjs-libraries/src/integrations/social/bluesky.provider.ts Added methods autoRepostPost and autoPlugPost for automated actions based on post engagement metrics.
libraries/nestjs-libraries/src/integrations/social/linkedin.page.provider.ts Added methods autoRepostPost and autoPlugPost for automated reposting and commenting based on likes.
libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts Introduced refreshToken method and updated existing methods for better error handling and API interaction.
libraries/nestjs-libraries/src/integrations/social/threads.provider.ts Added method autoPlugPost for creating posts based on likes.
libraries/nestjs-libraries/src/integrations/social/x.provider.ts Added methods autoRepostPost and autoPlugPost for automated Twitter interactions based on post engagement.

Poem

In the garden of plugs, we hop and play,
New methods sprout, brightening the day.
With each little change, our joy multiplies,
As we dance through the code, beneath the blue skies.
So here's to the updates, both big and small,
A whimsical world of plugs, we cherish them all! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d826a3b and f8703e0.

📒 Files selected for processing (22)
  • apps/backend/src/api/routes/integrations.controller.ts (3 hunks)
  • apps/frontend/src/app/(site)/plugs/page.tsx (1 hunks)
  • apps/frontend/src/components/layout/top.menu.tsx (1 hunks)
  • apps/frontend/src/components/plugs/plug.tsx (1 hunks)
  • apps/frontend/src/components/plugs/plugs.context.ts (1 hunks)
  • apps/frontend/src/components/plugs/plugs.tsx (1 hunks)
  • apps/workers/src/app/app.module.ts (1 hunks)
  • apps/workers/src/app/plugs.controller.ts (1 hunks)
  • apps/workers/src/app/posts.controller.ts (1 hunks)
  • libraries/helpers/src/decorators/plug.decorator.ts (1 hunks)
  • libraries/nestjs-libraries/src/bull-mq-transport-new/client.ts (1 hunks)
  • libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts (3 hunks)
  • libraries/nestjs-libraries/src/database/prisma/integrations/integration.service.ts (6 hunks)
  • libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts (2 hunks)
  • libraries/nestjs-libraries/src/database/prisma/schema.prisma (3 hunks)
  • libraries/nestjs-libraries/src/dtos/plugs/plug.dto.ts (1 hunks)
  • libraries/nestjs-libraries/src/integrations/integration.manager.ts (2 hunks)
  • libraries/nestjs-libraries/src/integrations/social/bluesky.provider.ts (4 hunks)
  • libraries/nestjs-libraries/src/integrations/social/linkedin.page.provider.ts (3 hunks)
  • libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts (3 hunks)
  • libraries/nestjs-libraries/src/integrations/social/threads.provider.ts (2 hunks)
  • libraries/nestjs-libraries/src/integrations/social/x.provider.ts (1 hunks)

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 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 b17727b into main Dec 9, 2024
7 of 8 checks passed
import { Button } from '@gitroom/react/form/button';
import React, { FC, useCallback, useEffect, useMemo, useState } from 'react';
import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
import useSWR, { mutate } from 'swr';

Check warning

Code scanning / ESLint

Disallow unused variables Warning

'mutate' is defined but never used.

Copilot Autofix AI about 1 month ago

To fix the problem, we need to remove the unused mutate import from the code. This will resolve the ESLint warning and clean up the code by removing unnecessary imports. The change should be made in the file apps/frontend/src/components/plugs/plug.tsx on line 10.

Suggested changeset 1
apps/frontend/src/components/plugs/plug.tsx

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/frontend/src/components/plugs/plug.tsx b/apps/frontend/src/components/plugs/plug.tsx
--- a/apps/frontend/src/components/plugs/plug.tsx
+++ b/apps/frontend/src/components/plugs/plug.tsx
@@ -9,3 +9,3 @@
 import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
-import useSWR, { mutate } from 'swr';
+import useSWR from 'swr';
 import { useModals } from '@mantine/modals';
EOF
@@ -9,3 +9,3 @@
import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
import useSWR, { mutate } from 'swr';
import useSWR from 'swr';
import { useModals } from '@mantine/modals';
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
[current.name]: current.value,
};
}, {} as any);
}, []);

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useMemo has a missing dependency: 'data.data'. Either include it or remove the dependency array.
};
}, {})
);
}, []);

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useMemo has a missing dependency: 'plug.fields'. Either include it or remove the dependency array.

toaster.show('Plug updated', 'success');
closeAll();
}, []);

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has missing dependencies: 'closeAll', 'fetch', 'plug.methodName', 'settings.providerId', and 'toaster'. Either include them or remove the dependency array.

setActivated(status === 'on');
},
[activated]

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has missing dependencies: 'data?.id' and 'fetch'. Either include them or remove the dependency array.
const fetch = useFetch();
const router = useRouter();
const [current, setCurrent] = useState(0);
const [refresh, setRefresh] = useState(false);

Check warning

Code scanning / ESLint

Disallow unused variables Warning

'refresh' is assigned a value but never used.

Copilot Autofix AI about 1 month ago

To fix the problem, we need to remove the unused variable refresh from the code. This involves deleting the line where refresh is declared and ensuring that no other part of the code depends on this variable. Since refresh is not used anywhere in the provided snippet, removing it will not affect the existing functionality.

Suggested changeset 1
apps/frontend/src/components/plugs/plugs.tsx

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/frontend/src/components/plugs/plugs.tsx b/apps/frontend/src/components/plugs/plugs.tsx
--- a/apps/frontend/src/components/plugs/plugs.tsx
+++ b/apps/frontend/src/components/plugs/plugs.tsx
@@ -20,3 +20,3 @@
   const [current, setCurrent] = useState(0);
-  const [refresh, setRefresh] = useState(false);
+  // const [refresh, setRefresh] = useState(false);
   const toaster = useToaster();
EOF
@@ -20,3 +20,3 @@
const [current, setCurrent] = useState(0);
const [refresh, setRefresh] = useState(false);
// const [refresh, setRefresh] = useState(false);
const toaster = useToaster();
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
const toaster = useToaster();
const load = useCallback(async () => {
return (await (await fetch('/integrations/list')).json()).integrations;
}, []);

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has a missing dependency: 'fetch'. Either include it or remove the dependency array.

const load2 = useCallback(async (path: string) => {
return await (await fetch(path)).json();
}, []);

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has a missing dependency: 'fetch'. Either include it or remove the dependency array.
return (
<div className="flex flex-col items-center mt-[100px] gap-[27px] text-center">
<div>
<img src="/peoplemarketplace.svg" />

Check warning

Code scanning / ESLint

Prevent usage of `<img>` element due to slower LCP and higher bandwidth. Warning

Using <img> could result in slower LCP and higher bandwidth. Consider using <Image /> from next/image to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
return (
<div className="flex flex-col items-center mt-[100px] gap-[27px] text-center">
<div>
<img src="/peoplemarketplace.svg" />

Check warning

Code scanning / ESLint

Enforce all elements that require alternative text have meaningful information to relay back to end user. Warning

img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.
await timer(2000);

await client.v2.tweet({
text: removeMd(fields.post.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢')).replace(

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This replaces only the first occurrence of '\n'.

Copilot Autofix AI about 1 month ago

To fix the problem, we should use a well-tested sanitization library to handle the user-controlled input properly. In this case, we can use the sanitize-html library to sanitize the fields.post content before processing it further. This will ensure that any potentially harmful content is properly escaped or removed.

  1. Install the sanitize-html library.
  2. Import the sanitize-html library in the file.
  3. Use the sanitize-html function to sanitize the fields.post content before replacing newlines.
Suggested changeset 2
libraries/nestjs-libraries/src/integrations/social/x.provider.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/libraries/nestjs-libraries/src/integrations/social/x.provider.ts b/libraries/nestjs-libraries/src/integrations/social/x.provider.ts
--- a/libraries/nestjs-libraries/src/integrations/social/x.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/x.provider.ts
@@ -1,2 +1,3 @@
 import { TwitterApi } from 'twitter-api-v2';
+import sanitizeHtml from 'sanitize-html';
 import {
@@ -111,7 +112,7 @@
 
+      const sanitizedPost = sanitizeHtml(fields.post);
       await client.v2.tweet({
-        text: removeMd(fields.post.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢')).replace(
+        text: removeMd(sanitizedPost.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢')).replace(
           '𝔫𝔢𝔴𝔩𝔦𝔫𝔢',
           '\n'
-        ),
         reply: { in_reply_to_tweet_id: id },
EOF
@@ -1,2 +1,3 @@
import { TwitterApi } from 'twitter-api-v2';
import sanitizeHtml from 'sanitize-html';
import {
@@ -111,7 +112,7 @@

const sanitizedPost = sanitizeHtml(fields.post);
await client.v2.tweet({
text: removeMd(fields.post.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢')).replace(
text: removeMd(sanitizedPost.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢')).replace(
'𝔫𝔢𝔴𝔩𝔦𝔫𝔢',
'\n'
),
reply: { in_reply_to_tweet_id: id },
package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -155,3 +155,4 @@
     "yargs": "^17.7.2",
-    "yup": "^1.4.0"
+    "yup": "^1.4.0",
+    "sanitize-html": "^2.13.1"
   },
EOF
@@ -155,3 +155,4 @@
"yargs": "^17.7.2",
"yup": "^1.4.0"
"yup": "^1.4.0",
"sanitize-html": "^2.13.1"
},
This fix introduces these dependencies
Package Version Security advisories
sanitize-html (npm) 2.13.1 None
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
naruki1024 pushed a commit to naruki1024/postiz-app that referenced this pull request Jan 10, 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.

1 participant