-
-
Notifications
You must be signed in to change notification settings - Fork 453
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
Addition of the ability to set/unset submission as original content #1133
Conversation
Added the `set_original_content()` function to set a submission as original content.
Huh, the check failed. What did I do wrong? Edit: Maybe it's the under-indentation. |
Getting to the logs for this is a bit annoying, but if you click through the "Details" on a check you eventually get to https://travis-ci.org/praw-dev/praw/jobs/609481225?utm_medium=notification&utm_source=github_status which shows the commands that failed - look for the red lines. You should install the Python code-formatting tool |
@leviroth Ah, I see now! I will try and fix it in a little bit. Thanks! Edit: Using Black Playground, finally got it to pass Travis. |
Okay, next noob question: How do I get it to pass coveralls? |
You need to add a test that runs your new code. You should probably put the test in |
@leviroth I've looked through the documentation and everything and honestly I'm just lost with how to integrate a proper test. Is it safe to add credentials to |
You shouldn't put your credentials directly in the code, since we don't want you posting those to GitHub. You should set them as environment variables. If you're using Linux/bash, you can do that with the syntax here. I suppose, since this is a moderation command, you'll need to have set up a post in a subreddit where you have mod powers. It probably makes sense to make a test subreddit for this, and maybe even a test account. Once you have a post that you can mark as OC, your tests should probably look like the spoiler and unspoiler tests here and here. |
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.
Hi @kungming2, thanks for the PR! While @leviroth helps you write tests, I've made some comments about the documentation of the new methods. What you have in terms of documentation looks good, and it only needs some minor improvements. Thanks for working on this!
I just dismissed my review because I'm happy with the documentation. Thanks for being so responsive! I'll leave it to @leviroth to review the rest of the PR and merge it when it's ready. |
|
@leviroth Heya, so I added the tests and they failed when I ran
Doesn't seem to be an issue with the endpoint since I ran the methods separately on a different script on the test post I specified and they worked perfectly fine. |
Added the `is_original_content` attribute to the typical attributes.
Ah, you should add the line The point of this is to explicitly mark tests that involve than one API call (plus one call to get authenticated). I think the OC code has to do this because it needs to know the subreddit, so PRAW first has to use the API to figure out which subreddit corresponds to the submission id. |
If you run this test locally, you should see that it creates some JSON files. After checking to make sure that your credentials aren't in those files, you should commit and push them as well. They're used to record your tests' HTTP traffic so that they can be replayed without actually having to talk to Reddit's server. |
@leviroth Where can I find said JSON files? Edit: I'm guessing the JSON files are not being created because the tests are failing still. After patching the sleep issue, I get this. I see that it's saying I have more than positional argument for the method but I formatted it the same as all the other tests. Sorry for the noob-ness of my questions!
|
Added JSON files for the `SubmissionModeration` methods `set_original_content()` and `unset_original_content()`.
@leviroth I think I figured it out based on reading some of the earlier commits to the test. Finally everything passed! Hopefully everything is good. |
I forgot about that underscore quirk; glad you figured it out. @jarhill0 The tests look good to me, but I don't have the permissions to merge this or do the required review. |
@leviroth Thanks for all your advice through this process! |
Oh, I thought you had permissions to make the approving review. In that case, I'll take a look at it myself in a bit. |
@jarhill0 An update: I realize now that submitters can mark their own submissions as OC but only on New Reddit. They can't do so on Old Reddit. So my text needs to be changed. How about from: This method can only be used by moderators of the subreddit that the submission belongs to, if the subreddit has enabled the beta feature in settings. to This method can be used both by the submission author on the desktop redesign and moderators of the subreddit that the submission belongs to, if the subreddit has enabled the beta feature in settings. Would this be okay and clear enough? |
Interesting. I just played around with it and it seems that the subreddit setting controls whether users can mark their own posts as OC, and moderators can mark them regardless of the setting. Can you confirm this behavior? Since both users and moderators can perform this action, maybe this method shouldn't belong to the |
Interesting. So from what I can tell, you have to enable the subreddit setting in order to be able to mark anything as OC as a mod on Old Reddit; the option appears to be always available to a moderator on New Reddit under the dropdown menu for a submission. (tested on r/translator) I can also confirm that the setting governs whether users can mark their own posts as OC. I placed it in the To me, |
Yep, I see that now. I would make the description read
|
@jarhill0 Done! |
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.
OK, everything that I looked at previously looks ready to merge now. I just took a look at the tests for the first time and I'm requesting changes there. Once that's done, I will merge the PR. Thank you!
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.
Terrific! It's ready for merging, as soon as it passes CI.
Thanks for your contribution, @kungming2! Great work on this PR. |
Thanks @jarhill0 ! Since this was my first pull request ever, hopefully the next time I contribute things will be smoother. :) |
Feature Summary and Justification
Added two methods to the
SubmissionModeration
class calledset_original_content()
andunset_original_content()
. These methods allows a moderator to set a post as "Original Content (OC)", a tag that is similar to the existing NSFW and Spoiler tags. Note that moderators can mark a post as "OC" on both Old and New Reddit; but submitters have to use New Reddit in order to mark their own posts as such. The feature itself has to be enabled in a subreddit's settings first.Though the admin announcement says the tag is only for New Reddit, the feature was backported to Old Reddit and is viewable on the old site as well.
This endpoint is not officially on the main API page, and the admin response of a year ago was to consider adding it to the API, but that was never done officially. Therefore there is a chance that this endpoint will be deprecated without warning in the future but it currently works and the feature has been fully operational on both desktop versions of Reddit for over a year and a half. The feature does not yet appear on the mobile app.
A submission with this tag will have another attribute
is_original_content
set toTrue
. If that submission's OC tag is subsequently removed, its attributeis_original_content
will become set toFalse
. Generic submissions may not haveis_original_content
as an attribute.Please note that unlike the NSFW tags, this has not been integrated by Reddit into search. Therefore, while
nsfw:true
works,oc:true
will not return any results from a search query.I have also tested this endpoint several times with my bot u/AssistantBOT.
Timeline
References