@@ -157,20 +157,25 @@ def send_pending_linkbacks_notification(linkback_type):
157
157
Send notification emails to all linkback moderators for all pending linkbacks
158
158
@param linkback_type: of CFG_WEBLINKBACK_LIST_TYPE
159
159
"""
160
- pending_linkbacks = get_all_linkbacks (linkback_type = CFG_WEBLINKBACK_TYPE ['TRACKBACK' ], status = CFG_WEBLINKBACK_STATUS ['PENDING' ])
160
+ pending_linkbacks = get_all_linkbacks (linkback_type = CFG_WEBLINKBACK_TYPE ['TRACKBACK' ],
161
+ status = CFG_WEBLINKBACK_STATUS ['PENDING' ],
162
+ limit = CFG_WEBLINKBACK_MAX_LINKBACKS_IN_EMAIL )
161
163
162
164
if pending_linkbacks :
163
- pending_count = len (pending_linkbacks )
165
+ pending_count = get_all_linkbacks (linkback_type = CFG_WEBLINKBACK_TYPE ['TRACKBACK' ],
166
+ status = CFG_WEBLINKBACK_STATUS ['PENDING' ],
167
+ full_count_only = True )
168
+
164
169
cutoff_text = ''
165
170
if pending_count > CFG_WEBLINKBACK_MAX_LINKBACKS_IN_EMAIL :
166
- cutoff_text = ' (Printing only the first %s requests)' % CFG_WEBLINKBACK_MAX_LINKBACKS_IN_EMAIL
171
+ cutoff_text = '(Printing only the first %s requests)' % CFG_WEBLINKBACK_MAX_LINKBACKS_IN_EMAIL
167
172
168
- content = """There are %(count)s new %(linkback_type)s requests which you should approve or reject%(cutoff)s:
173
+ content = """There are %(count)s new %(linkback_type)s requests which you should approve or reject %(cutoff)s:
169
174
""" % {'count' : pending_count ,
170
175
'linkback_type' : linkback_type ,
171
176
'cutoff' : cutoff_text }
172
177
173
- for pending_linkback in pending_linkbacks [ 0 : CFG_WEBLINKBACK_MAX_LINKBACKS_IN_EMAIL ] :
178
+ for pending_linkback in pending_linkbacks :
174
179
content += """
175
180
For %(recordURL)s from %(origin_url)s.
176
181
""" % {'recordURL' : generate_redirect_url (pending_linkback [2 ]),
@@ -180,15 +185,14 @@ def send_pending_linkbacks_notification(linkback_type):
180
185
send_email (CFG_SITE_ADMIN_EMAIL , email , 'Pending ' + linkback_type + ' requests' , content )
181
186
182
187
183
- def infix_exists_for_url_in_list (url , list_type ):
188
+ def infix_exists_for_url_in_list (url , url_list ):
184
189
"""
185
190
Check if an infix of a url exists in a list
186
191
@param url
187
- @param list_type, of CFG_WEBLINKBACK_LIST_TYPE
192
+ @param url_list
188
193
@return True, False
189
194
"""
190
- urls = get_url_list (list_type )
191
- for current_url in urls :
195
+ for current_url in url_list :
192
196
if current_url in url :
193
197
return True
194
198
return False
@@ -257,8 +261,8 @@ def perform_sendtrackback(req, recid, url, title, excerpt, blog_name, blog_id, s
257
261
<message>%s</message>
258
262
"""
259
263
260
- blacklist_match = infix_exists_for_url_in_list (url , CFG_WEBLINKBACK_LIST_TYPE ['BLACKLIST' ])
261
- whitelist_match = infix_exists_for_url_in_list (url , CFG_WEBLINKBACK_LIST_TYPE ['WHITELIST' ])
264
+ blacklist_match = infix_exists_for_url_in_list (url , get_url_list ( CFG_WEBLINKBACK_LIST_TYPE ['BLACKLIST' ]) )
265
+ whitelist_match = infix_exists_for_url_in_list (url , get_url_list ( CFG_WEBLINKBACK_LIST_TYPE ['WHITELIST' ]) )
262
266
263
267
# faulty request, url argument not set
264
268
if url in (CFG_WEBLINKBACK_SUBSCRIPTION_DEFAULT_ARGUMENT_NAME , None , '' ):
@@ -336,6 +340,7 @@ def delete_linkbacks_on_blacklist():
336
340
linkbacks .extend (list (get_all_linkbacks (status = CFG_WEBLINKBACK_STATUS ['REJECTED' ])))
337
341
linkbacks .extend (list (get_all_linkbacks (status = CFG_WEBLINKBACK_STATUS ['BROKEN' ])))
338
342
343
+ blacklist = get_url_list (CFG_WEBLINKBACK_LIST_TYPE ['BLACKLIST' ])
339
344
for linkback in linkbacks :
340
- if infix_exists_for_url_in_list (linkback [1 ], CFG_WEBLINKBACK_LIST_TYPE [ 'BLACKLIST' ] ):
345
+ if infix_exists_for_url_in_list (linkback [1 ], blacklist ):
341
346
remove_linkback (linkback [0 ])
0 commit comments