@@ -170,6 +170,72 @@ def set_warn(group_ids: list, value: int) -> None:
170170 ok (not warn_button (s ), "a full membership of an unticked group blocks warnings" )
171171
172172
173+ def check_feedlinks (b : Board ) -> None :
174+ """phpbbmodders/feedlinks: per-forum Atom/RSS links on the board index and the forum page, a valid RSS
175+ feed, and no links for forums set to none."""
176+ b .sql ("UPDATE phpbb_config SET config_value = '1' WHERE config_name IN ('feed_enable', 'feed_forum')" )
177+ forums = [int (r [0 ]) for r in b .sql ("SELECT forum_id FROM phpbb_forums WHERE forum_type = 1 ORDER BY left_id" )]
178+ shown , hidden = forums [0 ], forums [1 ] if len (forums ) > 1 else None
179+ b .sql ("UPDATE phpbb_forums SET forum_feedlinks = 3 WHERE forum_id = ?" , (shown ,))
180+ if hidden is not None :
181+ b .sql ("UPDATE phpbb_forums SET forum_feedlinks = 0 WHERE forum_id = ?" , (hidden ,))
182+ b .purge_cache ()
183+ guest = requests .Session ()
184+
185+ def links_to (page : str , path : str ) -> bool :
186+ """Whether page links to path (guests get ?sid=... appended to links)."""
187+ return re .search (re .escape (path ) + r'["?&]' , page ) is not None
188+
189+ index = guest .get (f"{ b .base } /index.php" ).text
190+ rss_path = b .route (f"rss/forum/{ shown } " )
191+ template = b .root / "styles/prosilver/template/forumlist_body.html"
192+ via = ("through the forumlist_body_forum_desc_after event"
193+ if "forumlist_body_forum_desc_after" in template .read_text (encoding = "utf-8" ) else "appended to the description" )
194+ ok (links_to (index , rss_path ) and links_to (index , f"feed/forum/{ shown } " ) and "feedlinks-list" in index ,
195+ f"board index shows Atom and RSS links for a forum set to both ({ via } )" )
196+ if hidden is not None :
197+ ok (not links_to (index , b .route (f"rss/forum/{ hidden } " )), "no links for a forum set to none" )
198+ ok (links_to (guest .get (f"{ b .base } /viewforum.php?f={ shown } " ).text , rss_path ), "the forum page shows its RSS link" )
199+ feed = guest .get (f"{ b .base } /{ rss_path } " )
200+ ok (feed .status_code == 200 and "<rss" in feed .text and "<channel>" in feed .text ,
201+ "the forum's RSS feed is served as RSS 2.0" )
202+ b .sql ("UPDATE phpbb_forums SET forum_feedlinks = 0 WHERE forum_id = ?" , (shown ,))
203+ b .purge_cache ()
204+ ok (not links_to (guest .get (f"{ b .base } /index.php" ).text , rss_path ), "links go away when the forum is set to none" )
205+
206+
207+ def check_topicclaim (b : Board ) -> None :
208+ """phpbbmodders/topicclaim: a moderator claims a topic with a note, other members see nothing, and the
209+ claim can be released (after confirmation)."""
210+ mod_pw = secrets .token_urlsafe (12 )
211+ mod_id = b .add_user ("tcmod" , mod_pw )
212+ b .add_user ("tcmember" , secrets .token_urlsafe (12 ))
213+ b .php (f"group_user_add(4, [{ mod_id } ]);" ) # Global moderators, whose role includes m_topicclaim
214+ b .purge_cache ()
215+ topic_id = int (b .sql ("SELECT topic_id FROM phpbb_topics WHERE topic_id = (SELECT MIN(topic_id) FROM phpbb_topics)" )[0 ][0 ])
216+ mod = requests .Session ()
217+ b .login (mod , "tcmod" , mod_pw )
218+ page_url = f"{ b .base } /{ b .route (f'topicclaim/{ topic_id } ' )} "
219+
220+ def claims () -> list :
221+ return b .sql ("SELECT user_id, claim_note FROM phpbb_topicclaim_claims WHERE topic_id = ?" , (topic_id ,))
222+
223+ action , fields = form_fields (mod .get (page_url ).text , "topicclaim" )
224+ post_back (mod , b .base , page_url , action , {** fields , "topicclaim_note" : "probe note" , "topicclaim_action" : "claim" })
225+ rows = claims ()
226+ ok (len (rows ) == 1 and int (rows [0 ][0 ]) == mod_id and rows [0 ][1 ] == "probe note" ,
227+ "a moderator claims a topic with a note" )
228+ ok ("topicclaim-notice" in mod .get (f"{ b .base } /viewtopic.php?t={ topic_id } " ).text ,
229+ "the topic page shows the claim to moderators" )
230+ ok ("topicclaim-notice" not in requests .get (f"{ b .base } /viewtopic.php?t={ topic_id } " ).text ,
231+ "guests don't see the claim" )
232+ action , fields = form_fields (mod .get (page_url ).text , "topicclaim" )
233+ confirm = post_back (mod , b .base , page_url , action , {** fields , "topicclaim_action" : "release" })
234+ action , fields = form_fields (confirm , "confirm" )
235+ post_back (mod , b .base , page_url , action , {** fields , "confirm" : "Yes" })
236+ ok (claims () == [], "the claim is released after confirming" )
237+
238+
173239def check_wiki (b : Board ) -> None :
174240 # Articles and a post stored through phpBB's own text parser, so the
175241 # extension's [[ ]] markup is parsed exactly as on a real board.
@@ -1568,6 +1634,8 @@ def follow_refresh(body: str) -> tuple:
15681634
15691635CHECKS = {
15701636 "phpbbmodders/prunenotifications" : check_prunenotifications ,
1637+ "phpbbmodders/feedlinks" : check_feedlinks ,
1638+ "phpbbmodders/topicclaim" : check_topicclaim ,
15711639 "phpbbmodders/seenotes" : check_seenotes ,
15721640 "phpbbmodders/autodbbackup" : check_autodbbackup ,
15731641 "phpbbmodders/elonw" : check_elonw ,
0 commit comments