Skip to content
This repository
  • 5 commits
  • 4 files changed
  • 0 comments
  • 2 contributors
1  r2/r2/config/templates.py
@@ -69,6 +69,7 @@ def api(type, cls):
69 69
 api('flaircsv', FlairCsvJsonTemplate)
70 70
 
71 71
 api('subredditstylesheet', StylesheetTemplate)
  72
+api('subredditstylesheetsource', StylesheetTemplate)
72 73
 api('createsubreddit', SubredditSettingsTemplate)
73 74
 
74 75
 api('modaction', ModActionTemplate)
4  r2/r2/controllers/error.py
@@ -147,7 +147,9 @@ def send429(self):
147 147
         return template.render(logo_url=static(g.default_header_url))
148 148
 
149 149
     def send503(self):
150  
-        response.headers["Retry-After"] = str(request.environ["retry_after"])
  150
+        retry_after = request.environ.get("retry_after")
  151
+        if retry_after:
  152
+            response.headers["Retry-After"] = str(retry_after)
151 153
         return request.environ['usable_error_content']
152 154
 
153 155
     def GET_document(self):
25  r2/r2/controllers/health.py
@@ -20,35 +20,34 @@
20 20
 # Inc. All Rights Reserved.
21 21
 ###############################################################################
22 22
 
23  
-from threading import Thread
24  
-import os
25  
-import time
26 23
 import json
  24
+import os
27 25
 
  26
+from pylons import g, request, response
28 27
 from pylons.controllers.util import abort
29  
-from pylons import c, g, response
30 28
 
31  
-from reddit_base import MinimalController
32  
-from r2.lib.amqp import worker
33  
-from r2.lib.validator import *
  29
+from r2.controllers.reddit_base import MinimalController
34 30
 from r2.lib import promote
35 31
 
36 32
 
37 33
 class HealthController(MinimalController):
38  
-    def post(self):
39  
-        pass
40  
-
41 34
     def try_pagecache(self):
42 35
         pass
43 36
 
44 37
     def pre(self):
45 38
         pass
46 39
 
  40
+    def post(self):
  41
+        pass
  42
+
47 43
     def GET_health(self):
48  
-        c.dontcache = True
49  
-        response.headers['Content-Type'] = 'text/plain'
  44
+        if os.path.exists("/var/opt/reddit/quiesce"):
  45
+            request.environ["usable_error_content"] = "No thanks, I'm full."
  46
+            abort(503)
  47
+
  48
+        response.content_type = "application/json"
50 49
         return json.dumps(g.versions, sort_keys=True, indent=4)
51 50
 
52 51
     def GET_promohealth(self):
53  
-        response.headers['Content-Type'] = 'text/plain'
  52
+        response.content_type = "application/json"
54 53
         return json.dumps(promote.health_check())
7  r2/r2/lib/pages/things.py
@@ -181,7 +181,12 @@ class MessageButtons(PrintableButtons):
181 181
     def __init__(self, thing, delete = False, report = True):
182 182
         was_comment = getattr(thing, 'was_comment', False)
183 183
         permalink = thing.permalink
184  
-        can_reply = c.user_is_loggedin and getattr(thing, "repliable", True)
  184
+        # don't allow replying to self unless it's modmail
  185
+        valid_recipient = (thing.author_id != c.user._id or
  186
+                           thing.sr_id)
  187
+        can_reply = (c.user_is_loggedin and
  188
+                     getattr(thing, "repliable", True) and
  189
+                     valid_recipient)
185 190
 
186 191
         PrintableButtons.__init__(self, "messagebuttons", thing,
187 192
                                   profilepage = c.profilepage,

No commit comments for this range

Something went wrong with that request. Please try again.