... |
... |
@@ -1,1 +1,38 @@ |
1 |
|
-a |
|
1 |
+{{groovy}} |
|
2 |
+def xwiki = xcontext.getXWiki() |
|
3 |
+def context = xwiki.getXWikiContext() |
|
4 |
+def userDocs = xwiki.getSpaceDocsName("XWiki", context) |
|
5 |
+ |
|
6 |
+def maxDeletes = 20 |
|
7 |
+def deleteCounter = 0 |
|
8 |
+ |
|
9 |
+userDocs.each { username -> |
|
10 |
+ if (deleteCounter >= maxDeletes) { |
|
11 |
+ return |
|
12 |
+ } |
|
13 |
+ |
|
14 |
+ if (username in ["Admin", "AdminAngriff", "TelegramBot", "testuser", "XWikiGuest", "SuperAdmin", |
|
15 |
+ "XWikiPreferences", "XWikiRights", "XWikiUsers", "XWikiAllGroup", "XWikiAdminGroup", |
|
16 |
+ "XWikiEditorsGroup", "XWikiReadOnlyGroup", "OfficeServer", "PageAdministration", |
|
17 |
+ "Extensions", "History", "Updater", "AvailableMacros", "XWikiSyntaxGuide", "Index", |
|
18 |
+ "Attachments", "DeletedAttachments", "DeletedPages", "OrphanedPages", "Tree", |
|
19 |
+ "ExternalLinks", "Results", "Macros", "SolrSearchAdministration", "DataTypes", |
|
20 |
+ "OfficeImporter", "XWikiAdvancedAdministrationTools", "XWikiProCommons", "ZoneCode"]) { |
|
21 |
+ println "Skipping real/system page: $username" |
|
22 |
+ } else if (username ==~ /^[0-9a-z]{6}$/) { |
|
23 |
+ def fullName = "XWiki.${username}" |
|
24 |
+ def doc = xwiki.getDocument(fullName, context) |
|
25 |
+ if (doc && doc.getObject("XWiki.XWikiUsers")) { |
|
26 |
+ xwiki.deleteDocument(doc, context) |
|
27 |
+ println "Deleted bot page: $username" |
|
28 |
+ deleteCounter++ |
|
29 |
+ } else { |
|
30 |
+ println "Skipping page without user object: $username" |
|
31 |
+ } |
|
32 |
+ } else { |
|
33 |
+ println "Skipping normal page: $username" |
|
34 |
+ } |
|
35 |
+} |
|
36 |
+println "✅ Deleted ${deleteCounter} bot pages in this batch." |
|
37 |
+{{/groovy}} |
|
38 |
+ |