-
-
Notifications
You must be signed in to change notification settings - Fork 717
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
Fix superadmin access #2307 with user-posted media #2318
Fix superadmin access #2307 with user-posted media #2318
Conversation
WalkthroughThe update involves modifying the Changes
Assessment against linked issues
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Our Pull Request Approval ProcessWe have these basic policies to make the approval process smoother for our volunteer team. Testing Your CodePlease make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:
The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
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: 1
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/resolvers/Organization/posts.ts (2 hunks)
Additional comments not posted (2)
src/resolvers/Organization/posts.ts (2)
92-92
: RenameobjectList
toposts
in the return statement to match the new variable name and improve readability.
30-34
: Ensure all calls to theposts
resolver are updated to pass thecontext
parameter.
src/resolvers/Organization/posts.ts
Outdated
imageUrl: post.imageUrl ? `${context.apiRootUrl}${post.imageUrl}` : null, | ||
videoUrl: post.videoUrl ? `${context.apiRootUrl}${post.videoUrl}` : null, |
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.
Refactor URL construction to handle potential leading slashes in imageUrl
and videoUrl
.
- imageUrl: post.imageUrl ? `${context.apiRootUrl}${post.imageUrl}` : null,
- videoUrl: post.videoUrl ? `${context.apiRootUrl}${post.videoUrl}` : null,
+ imageUrl: post.imageUrl ? new URL(post.imageUrl, context.apiRootUrl).toString() : null,
+ videoUrl: post.videoUrl ? new URL(post.videoUrl, context.apiRootUrl).toString() : null,
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.
imageUrl: post.imageUrl ? `${context.apiRootUrl}${post.imageUrl}` : null, | |
videoUrl: post.videoUrl ? `${context.apiRootUrl}${post.videoUrl}` : null, | |
imageUrl: post.imageUrl ? new URL(post.imageUrl, context.apiRootUrl).toString() : null, | |
videoUrl: post.videoUrl ? new URL(post.videoUrl, context.apiRootUrl).toString() : null, |
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.
@palisadoes are you talking about these two ?
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.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
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.
@lokeshsingh3721 Please address this
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.
@lokeshsingh3721 Please address this
I am sorry for stretching this out but i think I have already made these changes and i am not seeing any other suggestions . Can you please point out or share screenshots of another changes ?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2318 +/- ##
===========================================
+ Coverage 98.17% 98.50% +0.32%
===========================================
Files 184 349 +165
Lines 10767 25189 +14422
Branches 835 2354 +1519
===========================================
+ Hits 10571 24813 +14242
- Misses 186 373 +187
+ Partials 10 3 -7 ☔ View full report in Codecov by Sentry. |
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: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/resolvers/Organization/posts.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/resolvers/Organization/posts.ts
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.
const context = { apiRootUrl: undefined }; | ||
|
||
const formattedPost2 = { | ||
...testPost2?.toObject(), | ||
imageUrl: testPost2?.imageUrl | ||
? new URL(testPost2.imageUrl, context.apiRootUrl).toString() | ||
: null, | ||
videoUrl: testPost2?.videoUrl | ||
? new URL(testPost2.videoUrl, context.apiRootUrl).toString() | ||
: null, | ||
}; | ||
|
||
const formattedPost = { | ||
...testPost?.toObject(), | ||
imageUrl: testPost?.imageUrl | ||
? new URL(testPost.imageUrl, context.apiRootUrl).toString() | ||
: null, | ||
videoUrl: testPost?.videoUrl | ||
? new URL(testPost.videoUrl, context.apiRootUrl).toString() | ||
: null, | ||
}; | ||
|
||
expect(connection).toEqual({ | ||
edges: [ | ||
{ | ||
cursor: formattedPost2._id?.toString(), | ||
node: { | ||
...formattedPost2, | ||
_id: formattedPost2._id?.toString(), | ||
imageUrl: testPost?.imageUrl | ||
? new URL(testPost.imageUrl, context.apiRootUrl).toString() | ||
: null, | ||
videoUrl: formattedPost2?.videoUrl | ||
? new URL(formattedPost2.videoUrl, context.apiRootUrl).toString() | ||
: null, | ||
}, | ||
}, | ||
{ | ||
cursor: formattedPost._id?.toString(), | ||
node: { | ||
...formattedPost, | ||
_id: formattedPost?._id?.toString(), | ||
imageUrl: formattedPost?.imageUrl | ||
? new URL(formattedPost.imageUrl, context.apiRootUrl).toString() | ||
: null, | ||
videoUrl: formattedPost?.videoUrl | ||
? new URL(formattedPost.videoUrl, context.apiRootUrl).toString() | ||
: null, | ||
}, | ||
}, | ||
], | ||
pageInfo: { | ||
endCursor: testPost?._id.toString(), | ||
hasNextPage: false, | ||
hasPreviousPage: false, | ||
startCursor: testPost2?._id.toString(), | ||
}, | ||
totalCount, | ||
}); |
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.
Ensure apiRootUrl
is defined in the test context.
The context
object is initialized with apiRootUrl
as undefined
. This will cause the URL construction for imageUrl
and videoUrl
to fail, leading to incorrect test results. Consider initializing apiRootUrl
with a valid URL to accurately test the URL formatting logic.
- const context = { apiRootUrl: undefined };
+ const context = { apiRootUrl: 'http://example.com' };
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.
const context = { apiRootUrl: undefined }; | |
const formattedPost2 = { | |
...testPost2?.toObject(), | |
imageUrl: testPost2?.imageUrl | |
? new URL(testPost2.imageUrl, context.apiRootUrl).toString() | |
: null, | |
videoUrl: testPost2?.videoUrl | |
? new URL(testPost2.videoUrl, context.apiRootUrl).toString() | |
: null, | |
}; | |
const formattedPost = { | |
...testPost?.toObject(), | |
imageUrl: testPost?.imageUrl | |
? new URL(testPost.imageUrl, context.apiRootUrl).toString() | |
: null, | |
videoUrl: testPost?.videoUrl | |
? new URL(testPost.videoUrl, context.apiRootUrl).toString() | |
: null, | |
}; | |
expect(connection).toEqual({ | |
edges: [ | |
{ | |
cursor: formattedPost2._id?.toString(), | |
node: { | |
...formattedPost2, | |
_id: formattedPost2._id?.toString(), | |
imageUrl: testPost?.imageUrl | |
? new URL(testPost.imageUrl, context.apiRootUrl).toString() | |
: null, | |
videoUrl: formattedPost2?.videoUrl | |
? new URL(formattedPost2.videoUrl, context.apiRootUrl).toString() | |
: null, | |
}, | |
}, | |
{ | |
cursor: formattedPost._id?.toString(), | |
node: { | |
...formattedPost, | |
_id: formattedPost?._id?.toString(), | |
imageUrl: formattedPost?.imageUrl | |
? new URL(formattedPost.imageUrl, context.apiRootUrl).toString() | |
: null, | |
videoUrl: formattedPost?.videoUrl | |
? new URL(formattedPost.videoUrl, context.apiRootUrl).toString() | |
: null, | |
}, | |
}, | |
], | |
pageInfo: { | |
endCursor: testPost?._id.toString(), | |
hasNextPage: false, | |
hasPreviousPage: false, | |
startCursor: testPost2?._id.toString(), | |
}, | |
totalCount, | |
}); | |
const context = { apiRootUrl: 'http://example.com' }; | |
const formattedPost2 = { | |
...testPost2?.toObject(), | |
imageUrl: testPost2?.imageUrl | |
? new URL(testPost2.imageUrl, context.apiRootUrl).toString() | |
: null, | |
videoUrl: testPost2?.videoUrl | |
? new URL(testPost2.videoUrl, context.apiRootUrl).toString() | |
: null, | |
}; | |
const formattedPost = { | |
...testPost?.toObject(), | |
imageUrl: testPost?.imageUrl | |
? new URL(testPost.imageUrl, context.apiRootUrl).toString() | |
: null, | |
videoUrl: testPost?.videoUrl | |
? new URL(testPost.videoUrl, context.apiRootUrl).toString() | |
: null, | |
}; | |
expect(connection).toEqual({ | |
edges: [ | |
{ | |
cursor: formattedPost2._id?.toString(), | |
node: { | |
...formattedPost2, | |
_id: formattedPost2._id?.toString(), | |
imageUrl: testPost?.imageUrl | |
? new URL(testPost.imageUrl, context.apiRootUrl).toString() | |
: null, | |
videoUrl: formattedPost2?.videoUrl | |
? new URL(formattedPost2.videoUrl, context.apiRootUrl).toString() | |
: null, | |
}, | |
}, | |
{ | |
cursor: formattedPost._id?.toString(), | |
node: { | |
...formattedPost, | |
_id: formattedPost?._id?.toString(), | |
imageUrl: formattedPost?.imageUrl | |
? new URL(formattedPost.imageUrl, context.apiRootUrl).toString() | |
: null, | |
videoUrl: formattedPost?.videoUrl | |
? new URL(formattedPost.videoUrl, context.apiRootUrl).toString() | |
: null, | |
}, | |
}, | |
], | |
pageInfo: { | |
endCursor: testPost?._id.toString(), | |
hasNextPage: false, | |
hasPreviousPage: false, | |
startCursor: testPost2?._id.toString(), | |
}, | |
totalCount, | |
}); |
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.
@lokeshsingh3721 Please address this
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.
@palisadoes, I've noted your directive to address the issue with the apiRootUrl
being undefined in the test context. As previously suggested, initializing apiRootUrl
with a valid URL, such as 'http://example.com'
, will ensure that the URL construction for imageUrl
and videoUrl
functions correctly in the test environment. This change should resolve the issue and provide accurate test results.
Please let me know if there's anything else you'd like to discuss or if you need further assistance with this modification!
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: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/resolvers/Organization/posts.spec.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/resolvers/Organization/posts.spec.ts
|
i have made all the changes suggested by Code Rabbit and all the tests are passed . |
@palisadoes do i need to change anything ? |
There are still 2 code rabbit suggestions that you have not addressed |
where to see them ? |
What kind of change does this PR introduce?
bugfix
Issue Number:
Fixes #2307
Did you add tests for your changes?
tested locally on the machine
Snapshots/Videos:
Screen.Recording.2024-05-21.at.11.55.04.AM.mov
If relevant, did you update the documentation?
No need
Summary
There was an issue with organization's post resolver which was not letting the super-admin accessing the organization in which user posted the media.
Does this PR introduce a breaking change?
NO
Other information
Have you read the contributing guide?
Yes
Summary by CodeRabbit
New Features
imageUrl
andvideoUrl
based on the context, ensuring URLs are always up-to-date.Bug Fixes