Commit Graph

7826 Commits

Author SHA1 Message Date
Chad Birch
8f58a8fe00 Send actual ip when preventing private IP storage
This will make it easier to investigate the cause of the issue when we
have an alert from the graphite event rate going off.
2016-10-03 16:23:59 -06:00
William Ting
8ada8a3562 Revert "Search: Test new relevance2 relevancy"
This reverts commit 862ad8abfca5228c2abbc6309c0ceccac7745a43.
2016-09-28 13:46:46 -07:00
William Ting
0d4be6c244 Revert "Search: Fix sort menu for relevance2 test"
This reverts commit cd03ff38a84e4fc7a393c40af78f3c688a656b90.
2016-09-28 13:46:46 -07:00
Chad Birch
6106c6aa50 utils.timetext: use long to handle larger periods
timetext() deals with seconds, and it is currently giving weird results
for any time period that's longer than the max int value of 2147483647
seconds (about 68 years). The total number of seconds was already being
declared as a long, but one of the intermediate variables used in the
calculations was still an int and caused this issue.

This switches that variable to long as well, which resolves the problem.
The unused variable `count2` was also removed.
2016-09-28 12:10:22 -06:00
Brian Simpson
dbcf37afe2 wrapped: Use correct cache key when in the parent template 2016-09-26 13:30:43 -07:00
Ricky Ramirez
acdd4ffc62 wrapped.pyx: Use hash for cache_key(). 2016-09-26 13:30:39 -07:00
Peter Wildani
56666ee64b Add custom delimiters to ConfigValue.
This better supports nested complex values without going all the way to json syntax.
2016-09-26 09:29:27 -07:00
Chad Birch
284c6c5a12 UserRelManager.add(): catch CreationError
The add() function uses a get() at the beginning to avoid creating
duplicate relations, but concurrent requests can get past this point and
will throw a CreationError when the rel is committed. This handles that
case as well and returns None, the same as if the initial get()
determines that the rel already exists.
2016-09-22 13:29:06 -06:00
Chad Birch
3c7322a5b0 VWikiPage: catch ValueError from bad hex string
Currently, passing an invalid hex string as a wiki revision ID will
cause a 500, due to an unhandled ValueError. This catches it so that a
404 will be returned instead, similar to incorrect (but valid hex)
revision IDs.
2016-09-22 13:29:01 -06:00
Chad Birch
a57450aec3 Subreddit settings API: add allow_images 2016-09-22 13:28:55 -06:00
Chad Birch
3f48f18987 Don't store private IP addresses
Storing a private IP address for a user indicates that they're using an
internal "app" (mweb, modmail, etc.) that isn't passing along the user's
actual IP correctly.

Storing these IPs is not useful at all, so this commit checks if an IP
is private before storing it. However, getting to that point signals an
issue that needs to be resolved, so this will send a graphite event that
we can alert on to know that we have an app that needs to be adjusted.
2016-09-22 13:28:51 -06:00
Chad Birch
335b7fd9b5 LinksByUrlAndSubreddit: truncate very long urls
There are a few urls in the system that are extremely long (100,000+
chars). Cassandra's maximum key length is 64kb, so the whole url can't
be used as a key for these. This truncates the url at 65,000 characters
to prevent that from happening.

We should probably also implement a maximum url length, but this
prevents crashes from the pre-existing urls longer than that.
2016-09-22 13:28:36 -06:00
Chad Birch
7d6af3d397 utils.domain(): re.search() instead of findall()
Using findall is very slow on large urls, and completely unnecessary
since we only want the first match anyway.
2016-09-22 13:28:31 -06:00
Chad Birch
2683ce815c Fix empty locale errors in format_number/percent
The previous attempt at this fix (296f378b) still did not resolve the
issue.

This commit falls back to g.locale if c.locale is not set, instead of
trying to fall back to the LC_NUMERIC env variable.
2016-09-22 13:28:24 -06:00
Chad Birch
47fab5532d Revert "Fix empty locale errors in format_number/percent"
This reverts commit 296f378bc68f4732c17a23d0e188ef03b4e97501.
2016-09-22 13:28:19 -06:00
Chad Birch
cc571434b7 Send amqp messages for delete/remove/approve 2016-09-22 13:27:30 -06:00
Chad Birch
16d0b8dc66 POST_flaircsv: handle blank flair_csv param
This endpoint is currently crashing if nothing is supplied for the
flair_csv param. Returning immediately seems reasonable - no flair
updates requested, so there's nothing to do.
2016-09-22 13:25:19 -06:00
William Ting
1e49469d8f Remove redundant /jobs routing.
This line duplicates / shadows a previous /jobs redirect. You can tell it's not
being used by visiting /jobs on prod.
2016-09-22 11:36:57 -07:00
zeantsoi
05e947de43 Vagrantfile: remove adzerk plugin (#1694) 2016-09-21 17:56:29 -07:00
Brian Simpson
0d772e3035 Templated: Collect timings on rendering 2016-09-21 14:24:59 -07:00
Brian Simpson
a8ba98cc48 Templated: Remove unpublished timer in _render()
This was only used in the timing display bar thing, but wasn't very useful.
2016-09-21 14:24:59 -07:00
Brian Simpson
5c43a83547 Templated: Remove timer for g.timed_templates
These timings were never published and sort of are duplicates of the
"render.RENDER_CLASS_NAME.cached" timer in Templated._render.
2016-09-21 14:24:59 -07:00
Brian Simpson
7eb3ab2080 MinimalController: Stop logging useragent string on every request 2016-09-21 14:24:54 -07:00
Brian Simpson
8f6478992c FastlyCdnProvider: Implement get_client_ip and get_client_location
For now these depend on something setting the old CloudFlare headers
"CF-Connecting-IP" and "CF-IPCountry".
2016-09-20 15:48:39 -07:00
MelissaCole
7b58b61b1f Add FastlyCdnProvider 2016-09-20 15:45:37 -07:00
Dave Kasper
40b3436c40 Add contest mode flag again (messed up previous pr) 2016-09-16 09:49:54 -07:00
Brian Simpson
4754450e05 OAuth2AccessController: return 403 if g.disallow_db_writes
Some pools are read-only by setting g.disallow_db_writes True. If
a write is attempted there can be an exception. Instead of handling
the exception we should just immediately abort in OAuth2AccessController
because it will always need to write.
2016-09-14 14:12:33 -07:00
Brian Simpson
ca7e34a17b ThingJsonTemplate: Remove attributes only for Link and Comment
Link and Comment are now handled by the ThingTemplate class so these
special attribute handlers aren't needed.
2016-09-14 14:12:33 -07:00
Brian Simpson
55313b4faf Use faster ThingTemplate for LinkJsonTemplate 2016-09-14 14:12:33 -07:00
Brian Simpson
f0c6027670 LinkJsonTemplate: fixups 2016-09-14 14:12:24 -07:00
Brian Simpson
6fceb7b009 CommentJsonTemplate: pull some attributes out into methods
These attributes will be shared with LinkJsonTemplate
2016-09-14 14:06:23 -07:00
Matt Lee
f210486970 api: Add mp4 and gif variants to api response 2016-09-14 13:53:31 -07:00
Kevin O'Connor
38fbe363da Remove donate plugin. 2016-09-14 12:53:44 -07:00
Gregg Gajic
bd922104b9 _system_email: Fix NameError when calling Email.handler.add_to_queue 2016-09-13 18:16:12 -07:00
David Wick
faac2af02f tracker.py: Ensure /click endpoint doesn't modify destination urls
Omitting `keep_blank_values` was dropping blank query parameters.
Furthermore, converting the output of `parse_qsl` to a dictionary
was unnecessarily modifying the order of parameters since dicts
are not ordered. Fortunately `urllib.urlencode` also accepts a
sequence of two-element tuples and the order of parameters in
the encoded string will match the order of parameter tuples in the
sequence.
2016-09-13 15:34:41 -07:00
Brian Simpson
67a52d3c44 Change name to archived_slow to indicate subreddit lookup
Also replace all uses of the old "archived" property with archived_slow
or is_archived if the subreddit is available.
2016-09-12 15:43:54 -07:00
Brian Simpson
e0b47d0e47 Link.sort_if_suggested: Take optional sr parameter
This lets us skip the subreddit_slow call if we already have the subreddit.
Pass the parameter in LinkJsonTemplate.
2016-09-12 15:43:39 -07:00
Brian Simpson
f114b9e8e3 Comment: Add is_archived() to skip subreddit lookup when possible
Use this method in Comment.add_props when we already have the subreddit
2016-09-12 15:42:29 -07:00
Brian Simpson
4cc146d0cf Link: Add is_archived() to skip subreddit lookup when possible
Use this method in Link.add_props when we already have the subreddit
2016-09-12 15:42:29 -07:00
Brian Simpson
88ab588651 Link: Rename to can_comment_slow
This calls out the fact that there's an underlying subreddit_slow
2016-09-12 15:42:29 -07:00
Brian Simpson
49e66da3e8 Comment.archived: Always use subreddit_slow 2016-09-12 15:42:29 -07:00
Brian Simpson
ff39c50f82 Link.archived/can_comment: Always use subreddit_slow
There will never be a "subreddit" attribute already on the link.
That only gets added to Wrapped Link objects, and even if we called
wrapped_link.archived we'd fall through to Link.archived which no longer
has access to the "subreddit" attribute.
2016-09-12 15:42:29 -07:00
Brian Simpson
7b14b1000f Comment.subreddit_slow: Always stale and cleanup 2016-09-12 15:42:29 -07:00
Brian Simpson
383f2dcb22 Link.subreddit_slow: Use stale lookup 2016-09-12 15:42:23 -07:00
Kevin O'Connor
72a76f8030 Remove the meatspace plugin. 2016-09-12 15:37:56 -07:00
Brian Simpson
f35a92be76 valid_password: Handle ValueError raised by bcrypt.hashpw 2016-09-12 11:24:35 -07:00
Brian Simpson
47ff5815a7 get_trimmed_sr_dicts: Use get_sr_user_relations 2016-09-12 11:24:35 -07:00
Brian Simpson
7b2e18cebe Move get_sr_user_relations out of Subreddit.add_props 2016-09-12 11:24:35 -07:00
Brian Simpson
d171155f3a QueryBuilder: Batch sr_detail construction 2016-09-12 11:24:35 -07:00
Brian Simpson
4af9757ae7 Replace TrimmedSubredditJsonTemplate with get_trimmed_sr_dict
It's faster and simpler.
2016-09-12 11:24:35 -07:00