Skip to content

feat: Move https://mastodon.social to env variable for ability to cha… #708

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

halkeye
Copy link

@halkeye halkeye commented Apr 20, 2025

…nge instances per install

What kind of change does this PR introduce?

Feature

Why was this change needed?

#345

Other information:

eg: Did you discuss this change with anybody before working on it (not required, but can be a good idea for bigger changes). Any plans for the future, etc?

It seemed straight forward from the discussions of #345 and grepping code

Checklist:

Put a "X" in the boxes below to indicate you have followed the checklist;

  • I have read the CONTRIBUTING guide.
  • I checked that there were not similar issues or PRs already open for this.
  • This PR fixes just ONE issue (do not include multiple issues or types of change in the same PR) For example, don't try and fix a UI issue and include new dependencies in the same PR.

Summary by CodeRabbit

  • New Features
    • Added support for configuring the Mastodon instance URL via an environment variable, allowing users to connect to different Mastodon servers.
  • Chores
    • Updated environment variable examples to include the new Mastodon instance URL configuration.

Copy link

vercel bot commented Apr 20, 2025

@halkeye is attempting to deploy a commit to the Listinai Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

coderabbitai bot commented Apr 20, 2025

Walkthrough

The changes introduce the MASTODON_URL environment variable, allowing the Mastodon instance URL to be configured via the environment rather than being hardcoded. The .env.example file is updated to include this new variable. In the Mastodon provider modules, all usages of the previously hardcoded Mastodon instance URL are replaced with logic that retrieves the value from the environment variable, defaulting to the original URL if the variable is not set. This affects authentication, authorization, and posting methods.

Changes

File(s) Change Summary
.env.example Added MASTODON_URL variable with default value before Mastodon credentials.
libraries/nestjs-libraries/src/integrations/social/mastodon.custom.provider.ts Updated post method to use MASTODON_URL from environment, defaulting to https://mastodon.social.
libraries/nestjs-libraries/src/integrations/social/mastodon.provider.ts Updated generateAuthUrl, authenticate, and post methods to use MASTODON_URL from environment.

Sequence Diagram(s)

sequenceDiagram
    participant Env as Environment
    participant Provider as MastodonProvider
    participant Mastodon as MastodonInstance

    Note over Provider: On initialization or method call
    Provider->>Env: Read MASTODON_URL
    alt MASTODON_URL set
        Provider->>Mastodon: Use custom instance URL
    else Not set
        Provider->>Mastodon: Use https://mastodon.social
    end
    Mastodon-->>Provider: Respond to request (auth/post)
Loading

Poem

In the warren, code hops anew,
Mastodon’s home now set by you!
No longer fixed, the URL can change,
Across all posts, in methods’ range.
Environment whispers, “Hop this way!”
Rabbits cheer: “Configurable today!”
🐇🌐

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 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 ee0fa5b and 7f2892e.

📒 Files selected for processing (3)
  • .env.example (1 hunks)
  • libraries/nestjs-libraries/src/integrations/social/mastodon.custom.provider.ts (1 hunks)
  • libraries/nestjs-libraries/src/integrations/social/mastodon.provider.ts (3 hunks)
🔇 Additional comments (6)
.env.example (1)

75-75: Proper addition of the MASTODON_URL environment variable.

The new environment variable has been correctly added with a default value that matches the previously hardcoded URL. This change aligns well with the PR objective of making the Mastodon instance configurable.

libraries/nestjs-libraries/src/integrations/social/mastodon.custom.provider.ts (1)

77-77: Consistent fallback implementation for MASTODON_URL.

The environment variable is properly used with a fallback to the original hardcoded URL, maintaining backwards compatibility while enabling configuration.

libraries/nestjs-libraries/src/integrations/social/mastodon.provider.ts (4)

42-42: Correctly updated generateAuthUrl to use the environment variable.

The implementation properly reads from MASTODON_URL with a fallback to the original URL.


105-105: Consistent implementation in authenticate method.

This change maintains the pattern of using the environment variable with fallback, ensuring consistent behavior across the codebase.


182-182: Final consistent implementation in post method.

All references to the hardcoded Mastodon URL have been properly replaced with the environment variable pattern, completing the implementation of this feature.


39-183:

✅ Verification successful

Verify that all relevant instances have been updated.

The changes look good, but let's ensure we didn't miss any occurrences of the hardcoded URL.


🏁 Script executed:

#!/bin/bash
# Search for any remaining hardcoded instances of 'mastodon.social' in the codebase
rg -i "mastodon.social" --type ts

Length of output: 572


All hardcoded Mastodon URLs have been replaced with process.env.MASTODON_URL fallbacks
I verified occurrences in both mastodon.provider.ts and mastodon.custom.provider.ts—each use

process.env.MASTODON_URL || 'https://mastodon.social'

No remaining hardcoded URLs found.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @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.

Copy link

@baruchiro baruchiro left a comment

Choose a reason for hiding this comment

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

Assume that other instances have the same API

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