-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Conversation
WalkthroughThe pull request introduces modifications to the URL handling in multiple classes related to image and storybook management. The Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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:
- Moving the base URL to a configuration property
- 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 logicThe URL construction logic is currently duplicated across multiple controllers. Consider extracting this into a dedicated service class to:
- Ensure consistent URL formatting across the application
- Centralize protocol (HTTP/HTTPS) decisions
- 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
⛔ 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:
- The deprecated
bytes
field is required while its replacementcid
is optional - This could lead to invalid states where neither storage method is available
- The commented-out
@NotNull
ondominantColor
suggests incomplete requirements
Consider:
- Documenting the migration strategy from
bytes
tocid
- Adding validation to ensure at least one storage method is present
- 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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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(); |
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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(); |
Issue Number
Purpose
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.