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

refactor(ipfs): change ipfs url to pinata #1946

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

jo-elimu
Copy link
Member

Issue Number

Purpose

  • To load files faster. And to enable image optimization.

Technical Details

Testing Instructions

Screenshots


Format Checks

Note

Files in PRs are automatically checked for format violations with mvn spotless:check.

If this PR contains files with format violations, run mvn spotless:apply to fix them.

@jo-elimu jo-elimu self-assigned this Nov 12, 2024
@jo-elimu jo-elimu requested a review from a team as a code owner November 12, 2024 10:44
@jo-elimu jo-elimu linked an issue Nov 12, 2024 that may be closed by this pull request
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.

Project coverage is 15.97%. Comparing base (8ff4f9c) to head (c3d122b).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...t/storybook/StoryBookCreateFromEPubController.java 0.00% 4 Missing ⚠️
...ontent/multimedia/image/ImageCreateController.java 0.00% 2 Missing ⚠️
...view/StoryBookPeerReviewEventCreateController.java 0.00% 2 Missing ⚠️
...b/content/storybook/StoryBookCreateController.java 0.00% 2 Missing ⚠️
...web/content/storybook/StoryBookEditController.java 0.00% 2 Missing ⚠️
...book/chapter/StoryBookChapterCreateController.java 0.00% 2 Missing ⚠️
...book/chapter/StoryBookChapterDeleteController.java 0.00% 2 Missing ⚠️
.../paragraph/StoryBookParagraphCreateController.java 0.00% 2 Missing ⚠️
.../paragraph/StoryBookParagraphDeleteController.java 0.00% 2 Missing ⚠️
...ok/paragraph/StoryBookParagraphEditController.java 0.00% 2 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1946   +/-   ##
=========================================
  Coverage     15.97%   15.97%           
  Complexity      482      482           
=========================================
  Files           257      257           
  Lines          7852     7852           
  Branches        808      808           
=========================================
  Hits           1254     1254           
  Misses         6548     6548           
  Partials         50       50           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

coderabbitai bot commented Nov 12, 2024

Walkthrough

The pull request introduces modifications to the URL handling in multiple classes related to image and storybook management. The getUrl method in the Image class has been updated to change the base URL for IPFS content identifiers to a new Pinata URL, including an image width query parameter. Several controller classes have also updated their URL construction logic, changing from HTTPS to HTTP and simplifying how thumbnail URLs are generated. Overall, the changes focus on improving URL management without altering the core application logic.

Changes

File Change Summary
src/main/java/ai/elimu/model/content/multimedia/Image.java Updated getUrl method to change IPFS base URL and append query parameter for image width.
src/main/java/ai/elimu/web/content/multimedia/image/ImageCreateController.java Changed contentUrl protocol from HTTPS to HTTP; simplified embedThumbnailUrl to use image.getUrl().
src/main/java/ai/elimu/web/content/peer_review/StoryBookPeerReviewEventCreateController.java Updated contentUrl protocol from HTTPS to HTTP; simplified embedThumbnailUrl using CoverImage.getUrl().
src/main/java/ai/elimu/web/content/storybook/StoryBookCreateController.java Changed contentUrl protocol from HTTPS to HTTP; simplified embedThumbnailUrl using coverImage.getUrl().
src/main/java/ai/elimu/web/content/storybook/StoryBookCreateFromEPubController.java Updated contentUrl and embedThumbnailUrl protocols from HTTPS to HTTP; simplified URL retrieval.
src/main/java/ai/elimu/web/content/storybook/StoryBookEditController.java Changed contentUrl protocol from HTTPS to HTTP; simplified embedThumbnailUrl using coverImage.getUrl().
src/main/java/ai/elimu/web/content/storybook/chapter/StoryBookChapterCreateController.java Updated contentUrl protocol from HTTPS to HTTP; simplified embedThumbnailUrl using coverImage.getUrl().
src/main/java/ai/elimu/web/content/storybook/chapter/StoryBookChapterDeleteController.java Changed contentUrl protocol from HTTPS to HTTP; simplified embedThumbnailUrl using coverImage.getUrl().
src/main/java/ai/elimu/web/content/storybook/paragraph/StoryBookParagraphCreateController.java Updated contentUrl protocol from HTTPS to HTTP; simplified embedThumbnailUrl using coverImage.getUrl().
src/main/java/ai/elimu/web/content/storybook/paragraph/StoryBookParagraphDeleteController.java Changed contentUrl protocol from HTTPS to HTTP; simplified embedThumbnailUrl using coverImage.getUrl().
src/main/java/ai/elimu/web/content/storybook/paragraph/StoryBookParagraphEditController.java Updated contentUrl protocol from HTTPS to HTTP; simplified embedThumbnailUrl using coverImage.getUrl().

Assessment against linked issues

Objective Addressed Explanation
Change IPFS URL from https://ipfs.io/ipfs/<CID> to https://black-historic-wren-832.mypinata.cloud/ipfs/<CID> (#1945)

Possibly related PRs

  • Store images on IPFS #1936: Modifications to the Image class, including the addition of a cid field and updates to the getUrl() method, are directly related to the URL construction logic changes in this PR.
  • Add CID to CSV export #1938: Enhancements to the CSV export functionality by including the cid field from the Image model, relevant to managing image URLs and identifiers in the context of IPFS.

Suggested reviewers

  • jpatel3
  • Souvik-Cyclic
  • nya-elimu
  • vrudas

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 10

🧹 Outside diff range and nitpick comments (2)
src/main/java/ai/elimu/model/content/multimedia/Image.java (1)

41-41: Consider extracting URL and image width as configurable properties.

While the change aligns with the PR objectives, hardcoding the Pinata URL and image width might limit flexibility. Consider:

  1. Moving the base URL to a configuration property
  2. Making the image width configurable based on usage context

Example refactor:

- return "https://black-historic-wren-832.mypinata.cloud/ipfs/" + cid + "?img-width=640";
+ return ipfsConfig.getPinataBaseUrl() + cid + "?img-width=" + ipfsConfig.getDefaultImageWidth();
src/main/java/ai/elimu/web/content/storybook/paragraph/StoryBookParagraphEditController.java (1)

105-109: Consider centralizing URL construction logic

The URL construction logic is currently duplicated across multiple controllers. Consider extracting this into a dedicated service class to:

  1. Ensure consistent URL formatting across the application
  2. Centralize protocol (HTTP/HTTPS) decisions
  3. Make it easier to manage IPFS gateway changes

Would you like me to provide an example implementation of a URL service class?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8ff4f9c and c3d122b.

⛔ Files ignored due to path filters (3)
  • src/main/resources/db/content_PROD/eng/images.csv is excluded by !**/*.csv, !**/*.csv
  • src/main/resources/db/content_PROD/hin/images.csv is excluded by !**/*.csv, !**/*.csv
  • src/main/resources/db/content_PROD/tgl/images.csv is excluded by !**/*.csv, !**/*.csv
📒 Files selected for processing (11)
  • src/main/java/ai/elimu/model/content/multimedia/Image.java (1 hunks)
  • src/main/java/ai/elimu/web/content/multimedia/image/ImageCreateController.java (1 hunks)
  • src/main/java/ai/elimu/web/content/peer_review/StoryBookPeerReviewEventCreateController.java (1 hunks)
  • src/main/java/ai/elimu/web/content/storybook/StoryBookCreateController.java (1 hunks)
  • src/main/java/ai/elimu/web/content/storybook/StoryBookCreateFromEPubController.java (2 hunks)
  • src/main/java/ai/elimu/web/content/storybook/StoryBookEditController.java (1 hunks)
  • src/main/java/ai/elimu/web/content/storybook/chapter/StoryBookChapterCreateController.java (1 hunks)
  • src/main/java/ai/elimu/web/content/storybook/chapter/StoryBookChapterDeleteController.java (1 hunks)
  • src/main/java/ai/elimu/web/content/storybook/paragraph/StoryBookParagraphCreateController.java (1 hunks)
  • src/main/java/ai/elimu/web/content/storybook/paragraph/StoryBookParagraphDeleteController.java (1 hunks)
  • src/main/java/ai/elimu/web/content/storybook/paragraph/StoryBookParagraphEditController.java (1 hunks)
🔇 Additional comments (11)
src/main/java/ai/elimu/model/content/multimedia/Image.java (1)

Line range hint 19-31: Review entity state management strategy.

The current field annotations suggest potential issues:

  1. The deprecated bytes field is required while its replacement cid is optional
  2. This could lead to invalid states where neither storage method is available
  3. The commented-out @NotNull on dominantColor suggests incomplete requirements

Consider:

  1. Documenting the migration strategy from bytes to cid
  2. Adding validation to ensure at least one storage method is present
  3. Clarifying the requirements for dominantColor

Let's check for potential issues in the codebase:

src/main/java/ai/elimu/web/content/peer_review/StoryBookPeerReviewEventCreateController.java (1)

67-67: Verify Pinata URL implementation in CoverImage.getUrl()

The code now uses getCoverImage().getUrl() directly, which aligns with the PR objective of using Pinata URLs. However, we should verify that the getUrl() method has been properly updated to use the new Pinata URL format.

✅ Verification successful

Let me gather more information about the Image class implementation since the previous results show it's defined in src/main/java/ai/elimu/model/content/multimedia/Image.java.


Let me check one more thing to understand the relationship between CoverImage and Image classes.


Pinata URL implementation is correctly handled in Image class

Based on the examination of Image.java, the getUrl() method is properly implemented to return Pinata URLs when a CID is present. The method returns https://black-historic-wren-832.mypinata.cloud/ipfs/{cid}?img-width=640 for images stored in IPFS. Since we couldn't find a separate CoverImage class, it's likely that story book cover images are using the base Image class directly, which means they inherit this correct Pinata URL implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of getUrl() in CoverImage class
# Expected: Should find the new Pinata URL format

# Search for the CoverImage class implementation
ast-grep --pattern 'class CoverImage {
  $$$
  getUrl() {
    $$$
  }
  $$$
}'

# Search for any URL construction related to Pinata
rg -l "mypinata.cloud" 

Length of output: 312


Script:

#!/bin/bash
# Let's examine the Image class implementation and URL-related methods
cat src/main/java/ai/elimu/model/content/multimedia/Image.java

# Also check if CoverImage extends Image
rg -A 5 "class CoverImage" 

Length of output: 2094


Script:

#!/bin/bash
# Search for CoverImage class definition in the entire codebase
fd -e java -x grep -l "class CoverImage"

# Once we find the file, let's examine its content
fd -e java -x grep -A 10 "class CoverImage" {}

Length of output: 93

src/main/java/ai/elimu/web/content/storybook/StoryBookCreateController.java (1)

108-108: LGTM: Improved thumbnail URL generation

The change to use getUrl() directly aligns with the PR objectives of utilizing Pinata URLs for better performance and image optimization. This also simplifies the code by removing manual URL construction.

src/main/java/ai/elimu/web/content/storybook/chapter/StoryBookChapterCreateController.java (1)

113-113: Verify Image.getUrl() implementation for Pinata URL

According to the PR objectives, the IPFS URLs should be changed from ipfs.io to black-historic-wren-832.mypinata.cloud. Need to verify if the Image.getUrl() method has been updated to use the new Pinata URL format.

✅ Verification successful

Image.getUrl() implementation has been updated to use Pinata URL

Based on the search results, I found the Image.getUrl() implementation in src/main/java/ai/elimu/model/content/multimedia/Image.java:

public String getUrl() {
    if (cid != null) {
        return "https://black-historic-wren-832.mypinata.cloud/ipfs/" + cid + "?img-width=640";
    } else {
        return "/image/" + getId() + "_r" + getRevisionNumber() + "." + imageFormat.toString().toLowerCase();
    }
}

The method has been properly updated to use the new Pinata URL format "black-historic-wren-832.mypinata.cloud" instead of "ipfs.io" when returning IPFS URLs for images with CIDs.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if Image.getUrl() has been updated to use Pinata URL

# Search for getUrl method implementation in Image class
ast-grep --pattern 'class Image {
  $$$
  getUrl() {
    $$$
  }
  $$$
}'

# Search for any remaining references to ipfs.io
rg 'ipfs\.io'

Length of output: 91


Script:

#!/bin/bash
# Let's try a different approach to find the Image class and URL-related code

# Find files containing "Image" class definition
fd -e java -e kt -x rg -l "class Image"

# Search for getUrl method in any file
rg "getUrl.*\{" -A 5

# Search for Pinata-related configurations or URLs
rg -i "pinata|black-historic-wren-832"

Length of output: 97046

src/main/java/ai/elimu/web/content/storybook/paragraph/StoryBookParagraphCreateController.java (1)

118-118: LGTM: Simplified thumbnail URL retrieval.

The change to use getUrl() directly from the cover image aligns with the PR objectives of using Pinata URLs and simplifies the code by removing manual URL construction.

src/main/java/ai/elimu/web/content/storybook/paragraph/StoryBookParagraphEditController.java (1)

108-108: Verify IPFS URL transformation in Image.getUrl()

While this change simplifies the thumbnail URL construction by using getUrl(), we need to verify if the Image class has been updated to use the new Pinata IPFS URL as per the PR objectives.

✅ Verification successful

IPFS URL transformation is correctly implemented in Image.getUrl()

The Image.getUrl() method has been properly updated to use the Pinata IPFS URL format. When a CID is present, it returns the URL in the format: https://black-historic-wren-832.mypinata.cloud/ipfs/{cid}?img-width=640, which aligns with the PR objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the Image class implementation to verify IPFS URL changes
ast-grep --pattern 'class Image {
  $$$
  getUrl() {
    $$$
  }
  $$$
}'

# Backup: Search using ripgrep if the file is not in a supported language
rg -l "class Image" | xargs rg "getUrl.*\{" -A 10

Length of output: 1139

src/main/java/ai/elimu/web/content/storybook/paragraph/StoryBookParagraphDeleteController.java (1)

99-99: Verify the cover image URL format

Please verify that getUrl() returns the correct Pinata URL format (https://black-historic-wren-832.mypinata.cloud/ipfs/<CID>).

✅ Verification successful

Let me check the actual implementation of getUrl() in the Image class.


URL format is correctly implemented

The getUrl() method in the Image class correctly returns the Pinata URL in the format https://black-historic-wren-832.mypinata.cloud/ipfs/<CID> when a CID is present. It also includes an additional query parameter ?img-width=640 for image resizing. The implementation is consistent with the expected format.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the Image class's getUrl method returns the correct Pinata URL format

# Search for the Image class's getUrl implementation
ast-grep --pattern 'class Image {
  $$$
  getUrl() {
    $$$
  }
  $$$
}'

# Search for any URL construction related to IPFS or Pinata
rg -l 'ipfs\.io|mypinata\.cloud' 

Length of output: 319


Script:

#!/bin/bash
# Get the implementation of getUrl() method from Image class
cat src/main/java/ai/elimu/model/content/multimedia/Image.java

Length of output: 2065

src/main/java/ai/elimu/web/content/storybook/chapter/StoryBookChapterDeleteController.java (1)

141-141: LGTM! Clean URL generation.

The simplified thumbnail URL generation using getUrl() directly from the cover image aligns with the PR objective of using Pinata URLs and improves code maintainability.

src/main/java/ai/elimu/web/content/multimedia/image/ImageCreateController.java (1)

153-153: Verify the Pinata URL implementation

The change to use image.getUrl() aligns with the PR objective to use Pinata URLs. However, we should verify that the Image class correctly implements the new Pinata URL format.

✅ Verification successful

Let me gather more specific information about the Image class implementation.


Implementation of Pinata URL is correctly handled

The Image class properly implements the Pinata URL format in the getUrl() method. When a CID is present, it returns a properly formatted Pinata URL with the pattern https://black-historic-wren-832.mypinata.cloud/ipfs/{cid}?img-width=640. The fallback to the legacy URL format is also maintained when CID is not available. The usage of image.getUrl() in the ImageCreateController is therefore safe and consistent with the PR's objective.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the Image class implementation of getUrl()

# Search for the getUrl method implementation in Image class
echo "Searching for getUrl implementation..."
ast-grep --pattern 'getUrl() {
  $$$
}'

# Search for Pinata URL usage
echo "Searching for Pinata URL usage..."
rg -l "mypinata.cloud"

Length of output: 437


Script:

#!/bin/bash
# Get the Image class implementation focusing on URL-related code
echo "Image class URL implementation:"
rg -A 10 "getUrl|setUrl" src/main/java/ai/elimu/model/content/multimedia/Image.java

# Check for any URL transformation or Pinata-specific logic
echo -e "\nPinata URL handling in Image class:"
rg -B 2 -A 5 "mypinata.cloud" src/main/java/ai/elimu/model/content/multimedia/Image.java

Length of output: 1001

src/main/java/ai/elimu/web/content/storybook/StoryBookEditController.java (1)

228-228: LGTM: Improved URL generation for thumbnails

The change simplifies thumbnail URL generation by using the getUrl() method from the coverImage object. This aligns with the PR objective of transitioning to Pinata URLs and reduces code complexity.

Let's verify that the Image class properly implements the new Pinata URL format:

✅ Verification successful

Let me check the implementation of getUrl() in the Image class.


✓ URL generation for thumbnails is correctly implemented

The getUrl() method in Image class properly implements the Pinata URL format by returning https://black-historic-wren-832.mypinata.cloud/ipfs/{cid}?img-width=640 when cid is available, with a fallback to the legacy URL format. This confirms that the thumbnail URL generation in StoryBookEditController is working as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if Image class implements the new Pinata URL format

# Search for the getUrl implementation in Image class
ast-grep --pattern 'getUrl() {
  $$$
}'

# Backup: Search using ripgrep if ast-grep doesn't find it
rg -l "getUrl.*\{" --type java

Length of output: 133


Script:

#!/bin/bash
# Get the implementation of getUrl() method from Image class
rg -A 10 "getUrl\(\)" src/main/java/ai/elimu/model/content/multimedia/Image.java

Length of output: 445

src/main/java/ai/elimu/web/content/storybook/StoryBookCreateFromEPubController.java (1)

525-526: Verify the implementation of Image.getUrl().

The code now uses image.getUrl() to get the thumbnail URL. Let's verify that this method correctly implements the new Pinata URL format as specified in the PR objectives.

✅ Verification successful

Let me check the actual implementation of Image.getUrl() since we found the file.


The Image.getUrl() implementation correctly uses the new Pinata URL format

The implementation in Image.java shows that getUrl() correctly returns the Pinata URL format https://black-historic-wren-832.mypinata.cloud/ipfs/ when a CID is present, with an additional query parameter ?img-width=640 for image resizing. This aligns with the PR objectives for using Pinata's IPFS gateway.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the implementation of Image.getUrl() to ensure it uses the new Pinata URL format.

# Search for the Image class and its getUrl method
ast-grep --pattern 'class Image {
  $$$
  getUrl() {
    $$$
  }
  $$$
}'

# Search for any other occurrences of IPFS URLs
rg -l "ipfs.io/ipfs|mypinata.cloud/ipfs"

Length of output: 327


Script:

#!/bin/bash
# Get the implementation of Image.getUrl()
cat src/main/java/ai/elimu/model/content/multimedia/Image.java

Length of output: 2065

@@ -61,10 +61,10 @@ public String handleSubmit(
storyBookPeerReviewEventDao.create(storyBookPeerReviewEvent);

if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBookContributionEvent.getStoryBook().getId();
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBookContributionEvent.getStoryBook().getId();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security: Consider using HTTPS instead of HTTP

The URL protocol has been changed from HTTPS to HTTP. This is generally not recommended as HTTP connections are not encrypted and can be intercepted.

Apply this diff to use HTTPS:

-            String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBookContributionEvent.getStoryBook().getId();
+            String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBookContributionEvent.getStoryBook().getId();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBookContributionEvent.getStoryBook().getId();
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBookContributionEvent.getStoryBook().getId();

@@ -102,10 +102,10 @@ public String handleSubmit(
storyBookContributionEventDao.create(storyBookContributionEvent);

if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security Concern: Avoid using HTTP protocol

The URL protocol has been changed from HTTPS to HTTP, which is not recommended for modern web applications. Even for internal domains, HTTPS should be used to ensure secure communication and prevent man-in-the-middle attacks.

Apply this diff to use HTTPS:

-                String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
+                String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();

@@ -107,10 +107,10 @@ public String handleSubmit(
storyBookContributionEventDao.create(storyBookContributionEvent);

if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security Concern: Avoid using HTTP protocol

The URL protocol has been changed from HTTPS to HTTP, which is a security downgrade. Using HTTP exposes the content to potential man-in-the-middle attacks and is generally discouraged in modern web applications.

Apply this diff to use HTTPS:

-                String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
+                String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();

@@ -112,10 +112,10 @@ public String handleSubmit(
storyBookContributionEventDao.create(storyBookContributionEvent);

if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security concern: Avoid using HTTP protocol.

The URL protocol has been changed from HTTPS to HTTP. This is a security regression as HTTP traffic is unencrypted and susceptible to man-in-the-middle attacks.

Apply this diff to use HTTPS:

-                String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
+                String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();

@@ -102,10 +102,10 @@ public String handleSubmit(
storyBookContributionEventDao.create(storyBookContributionEvent);

if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security concern: Using HTTP instead of HTTPS

The URL protocol has been changed from HTTPS to HTTP. This is generally not recommended as it could expose user data to man-in-the-middle attacks.

Consider keeping HTTPS for secure communication:

-                String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
+                String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();

@@ -93,10 +93,10 @@ public String handleRequest(HttpSession session, @PathVariable Long id) {
storyBookContributionEventDao.create(storyBookContributionEvent);

if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security: Consider using HTTPS instead of HTTP

Using HTTP for content URLs may expose data to man-in-the-middle attacks. Consider using HTTPS to ensure secure communication.

Apply this diff to use HTTPS:

-            String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
+            String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();

@@ -135,10 +135,10 @@ public String handleRequest(HttpSession session, @PathVariable Long storyBookId,
storyBookContributionEventDao.create(storyBookContributionEvent);

if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid downgrading to HTTP protocol.

The URL protocol has been changed from HTTPS to HTTP, which is generally not recommended as it reduces security. Even for internal or notification purposes, it's best practice to use HTTPS.

Apply this diff to maintain HTTPS:

-            String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
+            String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();

@@ -149,8 +149,8 @@ public String handleSubmit(
imageContributionEventDao.create(imageContributionEvent);

if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/image/edit/" + image.getId();
String embedThumbnailUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/image/" + image.getId() + "_r" + image.getRevisionNumber() + "." + image.getImageFormat().toString().toLowerCase();
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/image/edit/" + image.getId();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security: Consider using HTTPS instead of HTTP

Using HTTP for content URLs may expose sensitive data in transit. Consider using HTTPS to ensure secure communication.

Apply this diff to use HTTPS:

-                String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/image/edit/" + image.getId();
+                String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/image/edit/" + image.getId();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/image/edit/" + image.getId();
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/image/edit/" + image.getId();

@@ -222,10 +222,10 @@ public String handleSubmit(
storyBookContributionEventDao.create(storyBookContributionEvent);

if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security Concern: Avoid using HTTP protocol

The URL protocol has been changed from HTTPS to HTTP, which is a security risk. Using HTTP can expose sensitive information during transit as the data is not encrypted.

Apply this diff to use HTTPS instead:

-                String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
+                String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();

Comment on lines +424 to +427
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String embedThumbnailUrl = null;
if (storyBook.getCoverImage() != null) {
embedThumbnailUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/image/" + storyBook.getCoverImage().getId() + "_r" + storyBook.getCoverImage().getRevisionNumber() + "." + storyBook.getCoverImage().getImageFormat().toString().toLowerCase();
embedThumbnailUrl = storyBook.getCoverImage().getUrl();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider security implications of using HTTP instead of HTTPS.

The change from HTTPS to HTTP for content URLs could expose user data to man-in-the-middle attacks. Unless there's a specific requirement (e.g., internal network constraints), it's recommended to use HTTPS for all external URLs.

-                String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
+                String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String contentUrl = "http://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String embedThumbnailUrl = null;
if (storyBook.getCoverImage() != null) {
embedThumbnailUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/image/" + storyBook.getCoverImage().getId() + "_r" + storyBook.getCoverImage().getRevisionNumber() + "." + storyBook.getCoverImage().getImageFormat().toString().toLowerCase();
embedThumbnailUrl = storyBook.getCoverImage().getUrl();
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/storybook/edit/" + storyBook.getId();
String embedThumbnailUrl = null;
if (storyBook.getCoverImage() != null) {
embedThumbnailUrl = storyBook.getCoverImage().getUrl();

@nya-elimu nya-elimu merged commit 046262d into main Nov 12, 2024
12 of 14 checks passed
@nya-elimu nya-elimu deleted the 1945-change-ipfs-url-to-pinata branch November 12, 2024 10:58
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.

Change IPFS URL to Pinata
2 participants