Commit Graph

6024 Commits

Author SHA1 Message Date
Chad Birch
f4325ab2e8 VExistingUname: strip surrounding spaces
This was causing all pages that use this validator to be unable to
handle leading/trailing spaces around the username, since when chkuser()
is called it will always return None due to their presence. Changing
this will make a lot of pages more tolerant with usernames, like the
message compose page, pages for banning users, adding them as approved
submitters or moderators, etc.
2015-05-22 12:42:46 -06:00
Jakeable
e772017d2e "Config" mod permission tooltip: add AutoModerator 2015-05-22 12:42:42 -06:00
Chad Birch
35339beeeb Remove public uses of "liked" and "disliked"
Replacing with "upvoted" and "downvoted" everywhere respectively.

This keeps the /liked and /disliked paths for user pages working for API
clients, but does a 301 redirect for non-API clients.
2015-05-21 15:56:25 -06:00
Keith Mitchell
5e954ec104 event-collector: Change "ip" to "client_ip" 2015-05-21 14:43:22 -07:00
Keith Mitchell
c216a5f6e7 event-collector: Send timestamps as ms since epoch 2015-05-21 14:43:22 -07:00
Keith Mitchell
868b0f5a95 event-collector: Begin sending submit events 2015-05-21 14:43:21 -07:00
Keith Mitchell
15ca73f898 event-collector: Add concept of "submit" event 2015-05-21 14:43:20 -07:00
xiongchiamiov
9470bb87ce Open Graph: use preview images
We use the [Open Graph protocol][0] to hint to Facebook and other sites what
images they should show as an on-site preview of reddit content.  For most of
our comments pages, that ends up being the thumbnail image, which is pretty
small.

We're now collecting preview images that are sometimes larger than the
thumbnails, so let's start using them when we can!

[0]: http://ogp.me/
2015-05-21 14:38:27 -07:00
Brian Simpson
b2075d49c9 Comment.add_props: Use the "subreddit" attribute added by the builder. 2015-05-21 17:24:36 -04:00
Brian Simpson
ab310a6b9d ThingJsonTemplate: use user_is_moderator attribute set on links/comments.
This lets us take advantage of the lookups that were batched in
Link.add_props and Comment.add_props rather than calling
Subreddit.is_moderator() multiple times.
2015-05-21 17:24:36 -04:00
Brian Simpson
b46e996edb Comment: check is_moderator in add_props and add attribute. 2015-05-21 17:24:36 -04:00
Brian Simpson
9b1e120d92 Link: check is_moderator in add_props and add attribute. 2015-05-21 17:24:36 -04:00
Brian Simpson
3532845fe2 Don't use replace_render when rendering api templates.
replace_render lets us stub out portions of the rendered output that change
frequently (e.g. score, rank in a listing, etc.) to make it more cachable,
but only html rendered output is cached.
2015-05-21 17:23:52 -04:00
Brian Simpson
38b41b2ae5 Add special handling for TrimmedSubredditJsonTemplate SRMember attributes.
This template class doesn't use Subreddit.add_props so we can't depend on attributes
set there.
2015-05-20 07:53:46 -04:00
Brian Simpson
1dcd8931a4 GET_about: use wrap_things to properly build subreddits for rendering. 2015-05-20 07:53:46 -04:00
Brian Simpson
6c09a27329 Subreddit: check for is_banned in add_props. 2015-05-20 07:53:46 -04:00
Brian Simpson
0b7cb58f44 Use batch lookedup moderator/subscriber/contributor for Subreddit json. 2015-05-20 07:53:46 -04:00
Brian Simpson
062718eaac Subreddit: simplify "contributor" attribute check.
Don't worry about whether the subreddit is not public.
2015-05-20 07:53:39 -04:00
Chad Birch
bc020743ef AutoMod: error if both "type: any" rules fail
If a rule definition specifies "type: any" (or does not specify type at
all), we try to create two separate rules for both comments and
submissions using the rule definition. If a particular type fails to
create, we just throw it away silently, considering this to mean that
the rule definition was actually only intended to apply to one type or
the other. However, if there is an error in the rule that results in
*both* the submission and comment attempts being thrown away, this means
that the entire rule will just end up being silently ignored. This adds
an error for that case, so that the user knows they need to fix their
definition.
2015-05-20 14:54:09 -06:00
Chad Birch
31a597c3a8 AutoMod: fix RuleTarget matches not being cleared
A RuleTarget's matches dict (which stores the results of the search
checks on that item) was only being cleared in the __init__ function, so
it was actually being retained across checks against multiple different
items. This meant that {{match}} placeholders would occasionally be
replaced by the result of a match from an entirely different item. This
change makes it so that the matches will be cleared at the start of each
check instead.
2015-05-20 14:54:09 -06:00
Chad Birch
9e4d166b7d AutoMod: disable inbox replies on comments
AutoModerator doesn't care about any of the replies to its comments
coming into its inbox, so we might as well avoid all this unnecessary
updating.
2015-05-20 14:54:09 -06:00
Chad Birch
ca4f7902c9 AutoMod: force domain and add context to permalink
The {{permalink}} placeholder (which is auto-included in messages and
modmails) has been using relative links, but some apps don't handle
these properly, so it's better to go back to using a full link with the
domain.

In addition, this makes it so that non-top-level comments will have
context=3 added on their permalinks.
2015-05-20 14:54:09 -06:00
Chad Birch
53b0e4a37f AutoMod: add "filter" action
This action lets AutoMod behave more like reddit's spam filter, so it
can remove something but leave it in the modqueue (and unmoderated if
it's a Link) for easier review by moderators.
2015-05-20 14:53:56 -06:00
Chad Birch
01c289ee34 AutoMod: add action_reason (replace report_reason) 2015-05-20 14:53:03 -06:00
Chad Birch
48e11ef5af AutoMod: add support for aliases on RuleComponents
This also rearranges the init logic for RuleTargets slightly, which will
have a side-effect of strengthening the validation a little bit. For
example, after this change it will not be possible to set "is_top_level"
on a submission, since that only makes sense for comments. Previously it
would have validated but been silently ignored.
2015-05-20 14:52:52 -06:00
Florence Yeun
44a168dfa7 Search: Remove unused sorts_menu_mapping
sorts_menu_mapping was replaced by g.search_sorts.
2015-05-20 11:00:34 -07:00
Florence Yeun
ce5c2636a3 Search: Expose sort parameter for subreddit search
Remove feature flag for subreddit relevancy and expose the sort
parameter for subreddit search.

This restores the `activity` sort option that was broken when
search was providerized.
2015-05-20 11:00:33 -07:00
MelissaCole
0297a2ee96 Overview page: Add [A] next to username if admin 2015-05-19 10:25:22 -07:00
Florence Yeun
229a2468e3 Multi API: Ignore empty multireddit GET parameter 2015-05-18 16:00:02 -07:00
Jordan Milne
d7acfce856 Fix some issues with unicode in URLs
First, `UrlParser.update_query` didn't like 7-bit unclean values.
`unicode()` should work everywhere `str()` did.

Second, the check for emedded NBSPs in `UrlParser.is_web_safe_url`
could be bypassed since `b'\xa0'` couldn't automatically be promoted
to unicode (thus `u'\xa0'` != b'\xa0'.) The check was fixed to handle
the NBSP char in either unicode or byte strings.
2015-05-18 15:27:15 -07:00
Chad Birch
d0108cfe3b AutoMod: fix overly-greedy match placeholder regex
The regex to find {{match}}-type placeholders is currently being
overly-greedy in cases with multiple placeholders in the same string.
For example, something like "Your post was removed because {{match}} is
in the title, please remove {{match}} from the title and resubmit." will
fail due to the regex spanning from the start of the first placeholder
until the end of the second. Replacing the "." in the regex with "[^}]"
will ensure that the matches stay confined to the same placeholder.
2015-05-18 14:32:42 -06:00
Chad Birch
ac6ba78708 AutoMod: lock around items in queue consumer
Race conditions between multiple automoderator_q consumers are causing
repeat actions (especially noticeable for things like leaving comments
or sending modmails) when multiple consumers end up processing the same
item at the same time (due to things like edits putting it in the queue
multiple times).
2015-05-18 14:32:38 -06:00
Chad Birch
5985a51513 AutoMod: catch and log invalid config errors
In the case of changes that cause previously-valid rule definitions to
start raising an exception, there may be some configurations that were
saved before the change was made, and so now contain an invalid
definition. This will cause the automod queue consumer(s) to hang if an
item from any of those subreddits needs to be checked, since it will be
unable to initialize the Ruleset to be able to process it. This commit
makes it so that items from subreddits with invalid configurations will
be skipped and an error logged.
2015-05-18 14:32:34 -06:00
Chad Birch
99431f6796 AutoMod: fix needs_media_data for compound checks
Previously, a rule would be considered to need media data if any checks
included a media check at all. For example, a check that looked at both
the submission's title and the media_title for a particular word would
not be applied to posts without media data. However, when in a compound
check like this, we should consider the media data optional, since there
are other non-media places that can be checked without it. This commit
does that, changing it so that a check will only cause the rule to
require media data if ALL of the fields being checked come from the
media, instead of if ANY of them do.
2015-05-18 14:32:29 -06:00
Chad Birch
dc16d770cb AutoMod: force placeholder replacements to unicode
Not forcing these to unicode is causing occasional UnicodeDecodeErrors
when the replacement contains non-ascii characters (seems especially
common from the media_ placeholders from oembed data).
2015-05-18 14:32:24 -06:00
Jordan Milne
5ffbff0270 Don't leak selftext through the meta description on deleted posts
Thanks to Anton Martynov for the report!
2015-05-15 13:28:52 -07:00
Jordan Milne
644f0988d7 Add a shim for requests' response.json to ease upgrading to 2.x
See http://docs.python-requests.org/en/latest/api/#migrating-to-1-x
for the rationale,

`.json()` also differs from `.json` in that it `raise`s instead of
returning `None` on a decoding error, but that shouldn't affect us
anywhere.

Conflicts:
	r2/r2/lib/media.py
2015-05-15 13:28:44 -07:00
Jordan Milne
f7790552be Use safer caching directives in Cache-Control
Some proxies ignore `no-cache`. That's bad when the responses are
credentialed.

We work around that by sending `Cache-Control: private, no-cache`,
since proxies generally won't strip that.
2015-05-15 13:28:35 -07:00
Jordan Milne
366ffc9dd7 Don't allow _any_ user to create an automatically created page. 2015-05-15 13:28:27 -07:00
Jordan Milne
912b224a1b Make sure special pages can only be created by mods with config perms
Thanks to a report by @pokechu022. Previously we were only checking
if the user was a moderator with permission to moderate the wiki.

This didn't affect anything until the automoderator config page was
added, as all other special pages are autocreated and don't pass
the `may_not_create` check for _any_ user.
2015-05-15 13:28:19 -07:00
Brian Simpson
6e300bead6 CommentPane: don't split cache on Account.pref_show_link_flair.
It doesn't effect rendering.
2015-05-15 15:14:17 -04:00
Brian Simpson
dca8ae32e2 Don't update search index every time a link gets a new comment. 2015-05-13 13:40:49 -04:00
Brian Simpson
375fa2a7d0 cast_vote: Update the search index less frequently.
The update frequency is inversely proportional to the total number of
votes cast on the thing.
2015-05-13 13:40:49 -04:00
Brian Simpson
7b72816891 Comment: define update_search_index() as a no-op.
Comments are not indexed, but they were being put into the "search_changes"
queue and then skipped when the message was processed.
2015-05-13 13:40:45 -04:00
MelissaCole
91c350a7f3 Remove signed as a default attr for Message
Old messages now have signed as True (default), so this reveals
the username is they reply to the old message.
2015-05-15 11:08:43 -07:00
MelissaCole
7576286b35 Display number of gildings even when user has no gold 2015-05-14 16:11:44 -07:00
MelissaCole
dad43b9fcd Make nonanonymous gilding message repliable
The anonymous gilding message allows for replies to the user. This will let
users reply to gilders that have revealed themselves instead of making them
start a new message thread.
2015-05-14 16:11:44 -07:00
MelissaCole
5ec4d98908 Hide friend label for anonymous messages
People could see who gilded them anonymously by having them as a friend and
including a specific note. This removes friend notes from messages that have a
display_author.
2015-05-14 16:11:44 -07:00
umbrae
dac71a3597 Gold expiration info: proper spacing with creddits to give 2015-05-14 11:51:26 -07:00
Brian Simpson
9cf982818f Use a body class to hide the "reply" and "report" buttons.
This allows us to not split the CommentPane cache on "can_reply".
2015-05-13 05:46:44 -04:00