Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moderator Tool Improvements #767

Draft
wants to merge 376 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
376 commits
Select commit Hold shift + click to select a range
66689b1
Set float_notice to false if it doesn't exist
MoshiKoi Sep 9, 2022
319aa37
Add support for pasting images into post text
Taeir Sep 9, 2022
756a491
add keyboard shortcut to the dashboard
superplane39 Sep 11, 2022
c13b529
Update from re-install
ArtOfCode- Sep 12, 2022
8c4a3f8
Start with migration to rails 6.0
Taeir Sep 12, 2022
f3957cf
Update schema
Taeir Aug 25, 2022
8df8b50
Fix warnings for case insensitive uniqueness validations
Taeir Aug 25, 2022
1cba6e4
Enable all safe new defaults
Taeir Aug 25, 2022
10b184c
Fix deprecated where.not usage
Taeir Aug 25, 2022
4ed47df
Fix content_type test
Taeir Aug 25, 2022
caaa40b
Update dependencies
Taeir Aug 25, 2022
07e0e9d
Please the linter gods
Taeir Aug 26, 2022
ba90ab6
Fix docker image
Taeir Aug 26, 2022
ee5b3df
Update spring, only load spring in development
Taeir Aug 26, 2022
2f6ef2a
Fix deprecation warnings for rmagick
Taeir Aug 26, 2022
cc73bd1
Check media type rather than content type
Taeir Aug 26, 2022
e9acd15
Enable other safe defaults (not using sidekiq or resque)
Taeir Aug 27, 2022
65a9559
Remove comments of safely updated packages
Taeir Sep 1, 2022
e77bd6f
Update redis library to v5
Taeir Sep 1, 2022
edd3a1c
Switch to rails 6 defaults and cleanup safe settings
Taeir Sep 1, 2022
6cf9a46
Fix files without .html extension
Taeir Sep 1, 2022
76bfd41
Run rails 6.1 update procedure
Taeir Sep 1, 2022
53897ef
Fix rails 6 image uploading
Taeir Sep 1, 2022
93bc9fb
Toggle safe rails 6.1 settings
Taeir Sep 1, 2022
eda29fa
Fix assets
Taeir Sep 1, 2022
a996013
Upgrade puma and clean up Gemfile
Taeir Sep 1, 2022
13823b6
Add missing optional mentions on belongs_to relations
Taeir Sep 2, 2022
0d2ac7e
Add missing translation
Taeir Sep 2, 2022
4997d7d
Fix flag fixture polymorphic relation without type
Taeir Sep 2, 2022
46d39b5
Fix categories controller test
Taeir Sep 2, 2022
2f293d7
Don't spam codidact.com during the tests
Taeir Sep 2, 2022
405c680
Update sass-rails to sassc-rails
Taeir Sep 3, 2022
dae5fb9
Fix help posts not editable
Taeir Sep 4, 2022
dc4d829
Ensure saved value is string in redis
Taeir Sep 9, 2022
b258ec2
Replace deprecated method with correct one
Taeir Sep 9, 2022
aa2250b
Fix caching
Taeir Sep 9, 2022
de53aaa
Fix rubocop errors
Taeir Sep 9, 2022
29ca3d3
Properly use redis in tests
Taeir Sep 9, 2022
08ecfcf
Use fully qualified name for redis
Taeir Sep 9, 2022
64c466c
Remove new defaults initializer
Taeir Sep 12, 2022
9e6b4d8
Start with migration to rails 6.0
Taeir Sep 12, 2022
e2026d3
Upgrade to rails 7
Taeir Sep 3, 2022
d882265
Update sass-rails to sassc-rails
Taeir Sep 3, 2022
e9a7d7f
Use sprockets 4
Taeir Sep 3, 2022
7591c7c
Switch to terser for js compression
Taeir Sep 4, 2022
e9f5ae9
Add schema version
Taeir Sep 4, 2022
bce0197
Switch to rails 7.0 defaults
Taeir Sep 4, 2022
1624284
Fix linter error
Taeir Sep 4, 2022
c5c7844
Update installation instructions
Taeir Sep 12, 2022
9146c80
Update schema for 7
ArtOfCode- Sep 12, 2022
3edb77b
Fix CI images
Taeir Sep 12, 2022
48da4af
Add ruby 3 support
Taeir Sep 12, 2022
d1166ab
Update omniauth
Taeir Sep 12, 2022
905f9cf
Add ability to create tags for mods
Taeir Sep 12, 2022
c649581
Prevent updating of tag names
Taeir Sep 12, 2022
3ce2275
Bump co-design version to 0.12.5
sau226 Jun 11, 2022
4992009
Add ability to follow new comment threads on a post; close #819
ArtOfCode- Sep 13, 2022
659f0c9
Changed error messages to avoid 'tags can't have more than 5 tags' co…
cellio Sep 20, 2022
4e42309
Apparently there is actually a save
MoshiKoi Sep 21, 2022
f3fdd56
Do not display closed posts in hot posts
Taeir Sep 15, 2022
170a091
Also hide locked posts
Taeir Sep 22, 2022
3326fd2
Report redis errors and inherit sockets for development
Taeir Sep 21, 2022
c2ada5f
Add missing relation
Taeir Sep 21, 2022
4ff4833
In seeding, actually link to the corresponding objects
Taeir Sep 21, 2022
d3fd074
Add required license field for communities
Taeir Sep 21, 2022
a38be9a
Revert redis to version 4 until issue is fixed and update settings
Taeir Sep 22, 2022
875fa72
Generalized wording on vote-summary page so it works for both you and…
cellio Sep 30, 2022
d5b7a4c
Don't rerender the preview if nothing changed
MoshiKoi Oct 9, 2022
f670c19
Add back still required install instructions
Taeir Oct 25, 2022
e91cdb3
Fix error in docker
Taeir Oct 27, 2022
5a77f8a
Ensure docker works out of the box
Taeir Oct 27, 2022
72b34d2
Add some notes on docker compose and Mac
Taeir Oct 27, 2022
d51d591
Also create storage config in docker
Taeir Oct 27, 2022
b739e2a
Wait until mysql is up properly
Taeir Oct 27, 2022
4e29a1c
Remove outdated config option
Taeir Oct 31, 2022
4094c66
Add net votes for each day to the vote summary
MoshiKoi Oct 10, 2022
e1350ab
Fix upload redirects
ArtOfCode- Nov 24, 2022
45459ad
Asyncify to fix error
ArtOfCode- Nov 24, 2022
b5ce5be
Bump nokogiri from 1.13.8 to 1.13.9
dependabot[bot] Nov 24, 2022
b588748
Bump commonmarker from 0.23.5 to 0.23.6
dependabot[bot] Nov 24, 2022
66c4d4d
Add SAML support
Taeir Sep 15, 2022
2c5b72c
Fix routes and update links in UI
Taeir Aug 19, 2022
6e1e20a
Add 2FA support
Taeir Aug 19, 2022
594bfb4
Apply code suggestions from ArtOfCode
Taeir Aug 23, 2022
9982de3
Fix mistake in attribute map
Taeir Aug 23, 2022
11b7bd6
Use helpers in devise
Taeir Aug 29, 2022
db4ac6a
Add SSO Sign in button on normal sign in page
Taeir Aug 29, 2022
c718a57
Fix links to SAML
Taeir Aug 29, 2022
a8ccc88
Add sign in with sso notice on registrations page
Taeir Aug 29, 2022
e8c6777
Add setting to control 2FA usage of SSO users
Taeir Nov 26, 2022
394df08
Disallow SSO users from changing email/password
Taeir Nov 26, 2022
8e2cf3e
Enforce that SSO users sign-in with SSO
Taeir Nov 26, 2022
2bb50a0
Allow disconnect account from SSO when mixed
Taeir Nov 26, 2022
54cf8a0
Check for mixed sign in before allowing SSO disconnect
Taeir Nov 26, 2022
1e5d6ed
Fix impersonation with SSO
Taeir Nov 26, 2022
bbd16d3
Consistently use Single Sign-On rather than Single Sign On
Taeir Nov 26, 2022
14149b1
Bump loofah from 2.18.0 to 2.19.1
dependabot[bot] Dec 13, 2022
cd68b1f
Bump rails-html-sanitizer from 1.4.3 to 1.4.4
dependabot[bot] Dec 14, 2022
48fd3ba
Remove caching that killed the server
ArtOfCode- Jan 2, 2023
f5ff803
changed order of fields (current pwd first, then new pwd & confirmation)
cellio Jan 2, 2023
75a7d8f
clarified field labels
cellio Jan 2, 2023
0688462
Fix double bracketed footnotes
MoshiKoi Dec 28, 2022
a7a67ac
Prevent selection of nonexistent parent tag
MoshiKoi Dec 29, 2022
d046eda
Fix tour test for the 3rd time
Taeir Jan 3, 2023
dac23b4
Move see-all-notifications button to top
MoshiKoi Jan 3, 2023
af05474
Add notifications tab to user page
MoshiKoi Jan 3, 2023
a6e6ca8
Fix CI issues
Taeir Jan 3, 2023
b158517
Apply consistently between sessions_controller and saml version
Taeir Jan 3, 2023
b0cd00a
Fix old internal link that no longer needs a number
trichoplax Jan 16, 2023
33c8d77
Add missing backtick that was hiding a heading from rendered markdown
trichoplax Jan 16, 2023
d2579cf
Replace abandoned heading number with heading wording
trichoplax Jan 16, 2023
392c42e
Use correct path in link text to avoid confusion
trichoplax Jan 16, 2023
8040dee
Add missing word and wrap very long line
trichoplax Jan 16, 2023
fef5828
Replace fake footnotes that unexpectedly linked off page
trichoplax Jan 16, 2023
13fc6cd
Remove space preventing italics from working in link text
trichoplax Jan 16, 2023
6a8d5b7
Replace .com with .org as apitester.com does not exist
trichoplax Jan 16, 2023
7ec63a8
Use apitester.org/app to avoid advert for mobile app
trichoplax Jan 16, 2023
4a90da4
Add missing # in internal link
trichoplax Jan 16, 2023
76c1717
mention ruby 3 in installation instructions
cellio Jan 13, 2023
3b62124
update Ruby version info (since we've moved to Ruby 3 I don't know if…
cellio Jan 13, 2023
04f8b02
Convert 'else if' to 'if' because it depends on data from the previou…
trichoplax Jan 9, 2023
e09675f
Remove check for old preferences schema from over 2 years ago
trichoplax Jan 9, 2023
fbea7cb
Add early return for most frequent case to reduce processing
trichoplax Jan 9, 2023
9c0b57c
Remove null check that is now redundant due to early return
trichoplax Jan 9, 2023
36c7d2b
Improve comment to state local variable contains preferences
trichoplax Jan 10, 2023
532f394
Reject only null & undefined, rather than all falsy local preferences
trichoplax Jan 10, 2023
2d1b3c4
Remove 'if' block made redundant by early returns
trichoplax Jan 10, 2023
41f888a
Store preferences on QPixel rather than window ('this')
trichoplax Jan 10, 2023
8775594
Suppress preferences retrieval when user is not signed in
trichoplax Jan 10, 2023
41431c2
Extract duplicated localStorage preferences code into a function
trichoplax Jan 11, 2023
c247bc8
Use unique localStorage key per user to avoid corruption
trichoplax Jan 11, 2023
963607f
Make 'if' explicit and include mandatory braces for code standards
trichoplax Jan 11, 2023
3b5ab24
Add the commas I forgot between new functions in QPixel object
trichoplax Jan 11, 2023
d2ea865
Change preference function to use early return
trichoplax Jan 11, 2023
3ea48a7
Extract common code into separate functions
trichoplax Jan 12, 2023
bde36fa
Add JavaScript documentation comments for new functions
trichoplax Jan 12, 2023
a6cb525
search results count added
duncanscode Jan 19, 2023
adcef28
Removed cateogry-meta
duncanscode Jan 20, 2023
793ea25
Bump globalid from 1.0.0 to 1.0.1
dependabot[bot] Jan 19, 2023
c1c0679
Add user id and signed in status to HTML body to avoid requests
trichoplax Jan 20, 2023
06760e8
Check signed in status on HTML body rather than making a request
trichoplax Jan 20, 2023
d2bebee
Access user id from HTML body rather than making a request
trichoplax Jan 20, 2023
4fd2a9d
Prevent request for user data unless there is a signed in user
trichoplax Jan 20, 2023
a364bcf
Use HTML data attribute userId instead of redundant signedIn
trichoplax Jan 20, 2023
51bc0cf
Update JS doc comment because function is no longer async
trichoplax Jan 20, 2023
2a4e996
Simplify QPixel._preferencesLocalStorageKey function
trichoplax Jan 20, 2023
0a69483
Bump rack from 2.2.4 to 2.2.6.2
dependabot[bot] Jan 19, 2023
038bcc3
Fix comparisons
Taeir Jan 3, 2023
fabd3e1
Remove unnecessary test
Taeir Jan 3, 2023
98275fe
Ensure tour tagset works with both strings and ints
Taeir Jan 19, 2023
f1998db
Add indicator if there are pending suggested edits
MoshiKoi Jan 3, 2023
66a881f
Cache whether there are pending suggestions
MoshiKoi Jan 3, 2023
e9dcdb6
Move pending logic to helper method
MoshiKoi Jan 3, 2023
1f60b2f
Update app/models/suggested_edit.rb
MoshiKoi Jan 22, 2023
5c4e79b
site -> community
superplane39 Jan 24, 2023
c7e829b
site -> community
superplane39 Jan 24, 2023
46f6f5b
Move check for signed in user from preferences function to preference
trichoplax Jan 22, 2023
d8ba668
Rename function to make clear it is internal only
trichoplax Jan 22, 2023
d029359
Cache '_fetchPreferences' returned promise to avoid redundant fetches
trichoplax Jan 22, 2023
5983d37
Add Stripe setting
ArtOfCode- Jan 30, 2023
5ce193a
Only load Stripe on donation pages
ArtOfCode- Jan 30, 2023
655d810
Add all-users email tool
ArtOfCode- Jan 30, 2023
641ccae
added info about using HTML details/summary (CommonMark doesn't support)
cellio Jan 25, 2023
41b2c66
Bump commonmarker from 0.23.6 to 0.23.7
dependabot[bot] Jan 25, 2023
f699079
Let only moderators (implicitly including admins) see who handled a flag
trichoplax Feb 1, 2023
e6c0193
Add missing indentation
trichoplax Feb 16, 2023
7054876
Fix one line if statement to match Code Standards
trichoplax Feb 16, 2023
5222fd7
Add missing semicolon
trichoplax Feb 16, 2023
8909606
Condense two queries into one for efficiency
trichoplax Feb 16, 2023
c372ba5
Switch 'if' branches to prevent leaking information about post existence
trichoplax Feb 16, 2023
9c4cf5a
Extract private thread checks into a 'before_action'
trichoplax Feb 16, 2023
8af6193
Remove debug printing code
trichoplax Feb 16, 2023
1f0f7ef
Remove comma and surplus 's', reduce number of lines
trichoplax Feb 16, 2023
f98fc8d
Make method name more explicit
trichoplax Feb 16, 2023
7fb8ae9
Improve wording and reduce number of lines
trichoplax Feb 16, 2023
174082c
Drop commas, improve wording, keep to 140 characters per line
trichoplax Feb 16, 2023
ddd4803
Keep to 140 characters per line
trichoplax Feb 16, 2023
d08f4af
Drop commas and keep to 140 characters per line
trichoplax Feb 16, 2023
409ac9d
Remove redundant usages of 'is_admin' covered by 'is_moderator'
trichoplax Feb 16, 2023
c4d05dc
Combine 2 return unless guards into 1 for readability
trichoplax Feb 16, 2023
2c50a2d
Remove unnecessary break in line
trichoplax Feb 16, 2023
96c798e
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Feb 16, 2023
c18fec3
Add missing closing parenthesis
trichoplax Feb 16, 2023
56a3cf6
Update database schema after running database migration for new mod t…
trichoplax Feb 16, 2023
6bcd6ce
Restrict thread followers to only moderators (including admins)
trichoplax Feb 17, 2023
80d3472
Ignore rbenv local file
luap42 Jun 25, 2023
01e910c
Merge branch 'develop' into luap42/moderator-tools-improvements
luap42 Jun 25, 2023
9f45967
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Aug 6, 2023
2f7ed40
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Aug 18, 2023
fd66bc8
Remove 'destroy user' from routes and user interface
trichoplax Aug 29, 2023
fa5e0bc
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Oct 25, 2023
048685b
Remove confusing development-only in joke from fail-ban interface
trichoplax Oct 25, 2023
f157386
Rename mod tools subsection to avoid Codidact-specific naming
trichoplax Oct 25, 2023
2e023fd
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Feb 13, 2024
277c2e7
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Mar 9, 2024
500ca1c
Fix post must exist error preventing sending a mod message
trichoplax Mar 9, 2024
65db2e7
Fix error due to lack of post when displaying moderator comment thread
trichoplax Mar 9, 2024
54e2e16
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Mar 18, 2024
320c578
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax May 11, 2024
5e68ba0
Update schema.rb following migrations
trichoplax May 11, 2024
7505007
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax May 25, 2024
18ba60c
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax May 29, 2024
ffa97d5
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Jun 3, 2024
d271b38
Split user mod tools sections and remove Codidact specific wording
trichoplax Jun 7, 2024
3b225c2
Use 'failban' rather than 'hellban' throughout code for consistency
trichoplax Jun 7, 2024
3f0926c
Style moderator tools tab as active on user profile
trichoplax Jun 7, 2024
a225fbc
Make mod tools Full Activity Log compatible with private comment threads
trichoplax Jun 24, 2024
fd9344b
Make mod tools Global Summary compatible with private comment threads
trichoplax Jun 26, 2024
4f07b2a
Improve wording of user mod tools page intro message
trichoplax Jun 27, 2024
2795ff0
Make impersonate section of user mod tools show correct side panels
trichoplax Jun 27, 2024
2acc08e
Make user mod tools tab remain highlighted when switching sections
trichoplax Jun 27, 2024
07d0088
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Jun 28, 2024
e1934a2
Include link to full thread for private messages
trichoplax Jun 28, 2024
7ecc843
Indicate when a user has no private messages or warnings
trichoplax Jun 28, 2024
b8e71c6
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Jul 5, 2024
c10685a
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Jul 8, 2024
ffa5f99
Remove tests for destroy user functionality that no longer exists
trichoplax Jul 8, 2024
948c139
Remove redundant rubocop disabling
trichoplax Jul 8, 2024
4980181
Use unless instead of if not thanks to rubocop
trichoplax Jul 8, 2024
e40e6de
Remove redundant whitespace
trichoplax Jul 8, 2024
68f8949
Remove duplicate of method
trichoplax Jul 8, 2024
a50dc14
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Jul 9, 2024
cf15160
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Jul 9, 2024
73f6abb
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Jul 23, 2024
96dc8a7
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Aug 29, 2024
61552d1
Fix missing mod messages in List Previous section
trichoplax Sep 1, 2024
973a98d
Remove redundancy from query
trichoplax Sep 1, 2024
85e9b41
Remove redundant safe navigation following explicit nil check
trichoplax Sep 1, 2024
e128a38
Use parentheses for consistency
trichoplax Sep 1, 2024
bfb45b2
Apply Taeir's suggestion from a comment on pull request 1009
trichoplax Sep 1, 2024
fd6a774
Reduce scope of variables no longer used outside method
trichoplax Sep 1, 2024
7947127
Reduce confusing variable reuse and mislabelling
trichoplax Sep 1, 2024
acc3c1c
Make maximum global suspension 1 year, like local suspensions
trichoplax Sep 1, 2024
40b4ce3
Reduce use of .present? for readability
trichoplax Sep 3, 2024
9c3f978
Adjust order and wording of Contact Privately notice
trichoplax Sep 5, 2024
6e781b8
Draw attention to the visibility to moderators of a private message
trichoplax Sep 6, 2024
8543bc7
Allow moderators (and implicitly admins) to view all private messages
trichoplax Sep 6, 2024
2ff6fa3
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Sep 11, 2024
0b2ad8c
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Sep 12, 2024
864c420
Allow notifications on a thread without a parent post
trichoplax Sep 13, 2024
d7b6b9d
Show username at top of private thread to avoid confusion
trichoplax Sep 13, 2024
033c662
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Sep 26, 2024
e1a5220
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Oct 3, 2024
61fadf6
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Oct 7, 2024
441d2ff
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Oct 14, 2024
c988e28
Merge branch 'develop' into luap42/moderator-tools-improvements
cellio Oct 16, 2024
71f62b7
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Oct 20, 2024
a5ab018
Merge branch 'develop' into luap42/moderator-tools-improvements
trichoplax Oct 25, 2024
5f32ee5
Merge branch 'develop' into luap42/moderator-tools-improvements
Oaphi Oct 26, 2024
4f9147d
rubocop fix
Oaphi Oct 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ $(document).on('ready', function() {
});
});

$(".is-partial-only:not(.open)").on("click", (evt) => {
if(evt.target.classList.contains("open")) return;
cellio marked this conversation as resolved.
Show resolved Hide resolved

evt.target.classList.add("open");
evt.stopPropagation();
})
cellio marked this conversation as resolved.
Show resolved Hide resolved

if (document.cookie.indexOf('dismiss_fvn') === -1 ) {
$('#fvn-dismiss').on('click', () => {
document.cookie = 'dismiss_fvn=true; path=/; expires=Fri, 31 Dec 9999 23:59:59 GMT';
Expand Down
32 changes: 32 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,35 @@ img.header--item-image {
.widget--header-link {
margin: 0 0 0 0.5em;
}


.is-partial-only:not(.open) {
max-height: 100px;
overflow: hidden;
position: relative;

&::after {
content: '';
position: absolute;
right: 0; left: 0;
bottom: 0;
height: 75px;
background-color: rgba(255, 255, 255, 0.5);
background: linear-gradient(#ffffff66, #fffffffa);
z-index: 10000000;
}

&::before {
content: 'expand';
position: absolute;
left: 50%;
transform: translate(-50%);
bottom: 10px;
z-index: 10000001;
padding: 5px 20px;
background-color: #ddd;
border: 1px solid #666;
border-radius: 15px;
cursor: pointer;
}
}
4 changes: 4 additions & 0 deletions app/assets/stylesheets/tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

.tabs {
margin-bottom: 1em;

.tabs--push {
flex-grow: 1;
}
}
16 changes: 16 additions & 0 deletions app/assets/stylesheets/users.scss
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,19 @@ $sizes: (16, 32, 40, 48, 64, 128, 256);
}
}
}


.modtools--sidebar {
margin-right: 1rem;
}
.modtools--usercard {
padding: 0.5rem;
}
.modtools-tbl-noborder {
th {
border-bottom-width: 1px !important;
width: 150px;
}
}

.mod-warnings-clear-form { display: inline; }
3 changes: 2 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,9 @@ def pull_categories
def check_if_warning_or_suspension_pending
return if current_user.nil?

global_warning = ModWarning.where(user: current_user, is_global: true, active: true).any?
warning = ModWarning.where(community_user: current_user.community_user, active: true).any?
cellio marked this conversation as resolved.
Show resolved Hide resolved
return unless warning
return unless global_warning || warning

# Ignore devise and warning routes
return if devise_controller? || ['custom_sessions', 'mod_warning', 'errors'].include?(controller_name)
Expand Down
59 changes: 52 additions & 7 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Provides mainly web actions for using and making comments.

# rubocop:disable Metrics/ClassLength
class CommentsController < ApplicationController
before_action :authenticate_user!, except: [:post, :show, :thread]
before_action :set_comment, only: [:update, :destroy, :undelete, :show]
Expand Down Expand Up @@ -56,11 +58,13 @@ def create_thread
def create
@comment_thread = CommentThread.find(params[:id])
@post = @comment_thread.post
if @post.comments_disabled && !current_user.is_moderator && !current_user.is_admin
render json: { status: 'failed', message: 'Comments have been disabled on this post.' }, status: :forbidden
return
elsif [email protected]_access?(current_user)
return not_found
unless @post.nil?
if @post.comments_disabled && !current_user.is_moderator && !current_user.is_admin
cellio marked this conversation as resolved.
Show resolved Hide resolved
render json: { status: 'failed', message: 'Comments have been disabled on this post.' }, status: :forbidden
return
elsif [email protected]_access?(current_user)
return not_found
end
end

body = params[:content]
Expand All @@ -82,6 +86,8 @@ def create
.where('link LIKE ?', "#{thread_url}%")
next if existing_notification.exists?

next if @post.nil?

title = @post.parent.nil? ? @post.title : @post.parent.title
follower.user.create_notification("There are new comments in a followed thread '#{@comment_thread.title}' " \
"on the post '#{title}'",
Expand All @@ -94,6 +100,12 @@ def create
end

def update
if @comment_thread&.is_private
flash[:danger] = 'This action is not permitted.'
redirect_to comment_thread_path(@comment_thread.id)
return
end

cellio marked this conversation as resolved.
Show resolved Hide resolved
before = @comment.content
if @comment.update comment_params
unless current_user.id == @comment.user_id
Expand All @@ -110,6 +122,12 @@ def update
end

def destroy
if @comment_thread&.is_private
flash[:danger] = 'This action is not permitted.'
redirect_to comment_thread_path(@comment_thread.id)
return
end

if @comment.update(deleted: true)
@comment_thread = @comment.comment_thread
unless current_user.id == @comment.user_id
Expand All @@ -123,6 +141,12 @@ def destroy
end

def undelete
if @comment_thread&.is_private
flash[:danger] = 'This action is not permitted.'
redirect_to comment_thread_path(@comment_thread.id)
return
end

if @comment.update(deleted: false)
@comment_thread = @comment.comment_thread
unless current_user.id == @comment.user_id
Expand Down Expand Up @@ -169,11 +193,23 @@ def thread_rename
return
end

if @comment_thread&.is_private && !current_user.is_moderator
flash[:danger] = 'This action is not permitted.'
redirect_to comment_thread_path(@comment_thread.id)
return
end

@comment_thread.update title: params[:title]
redirect_to comment_thread_path(@comment_thread.id)
end

def thread_restrict
if @comment_thread&.is_private && !current_user.is_moderator
flash[:danger] = 'This action is not permitted.'
redirect_to comment_thread_path(@comment_thread.id)
return
end

case params[:type]
when 'lock'
return not_found unless current_user.privilege?('flag_curate') && !@comment_thread.locked?
Expand Down Expand Up @@ -204,6 +240,12 @@ def thread_restrict
end

def thread_unrestrict
if @comment_thread&.is_private && !current_user.is_moderator
flash[:danger] = 'This action is not permitted.'
redirect_to comment_thread_path(@comment_thread.id)
return
end

case params[:type]
when 'lock'
return not_found unless current_user.privilege?('flag_curate') && @comment_thread.locked?
Expand Down Expand Up @@ -278,7 +320,7 @@ def check_if_parent_post_locked
end

def check_if_target_post_locked
check_if_locked(Post.find(params[:post_id]))
params[:post_id].present? && check_if_locked(Post.find(params[:post_id]))
end

def check_for_pings(thread, content)
Expand All @@ -302,12 +344,14 @@ def apply_pings(pings)
end

def comment_rate_limited
return false if @comment_thread&.is_private

recent_comments = Comment.where(created_at: 24.hours.ago..DateTime.now, user: current_user).where \
.not(post: Post.includes(:parent).where(parents_posts: { user_id: current_user.id })) \
.where.not(post: Post.where(user_id: current_user.id)).count
max_comments_per_day = SiteSetting[current_user.privilege?('unrestricted') ? 'RL_Comments' : 'RL_NewUserComments']

if ([email protected]_id == current_user.id || @post&.parent&.user_id == current_user.id) \
if (!@post&.user_id == current_user.id || @post&.parent&.user_id == current_user.id) \
&& recent_comments >= max_comments_per_day
comment_limit_msg = "You have used your daily comment limit of #{recent_comments} comments." \
' Come back tomorrow to continue commenting. Comments on own posts and on answers' \
Expand All @@ -326,3 +370,4 @@ def comment_rate_limited
false
end
end
# rubocop:enable Metrics/ClassLength
73 changes: 66 additions & 7 deletions app/controllers/mod_warning_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class ModWarningController < ApplicationController
before_action :verify_moderator, only: [:log, :new, :create, :lift]
before_action :verify_global_moderator, only: [:new_global, :create_global]

before_action :set_warning, only: [:current, :approve]
before_action :set_user, only: [:log, :new, :create, :lift]
before_action :set_user, only: [:log, :new, :create, :lift, :new_global, :create_global]

def current
render layout: 'without_sidebar'
Expand All @@ -21,7 +22,24 @@ def approve
end

def log
@warnings = ModWarning.where(community_user: @user.community_user).order(created_at: :desc).all
@warnings = ModWarning.where(community_user: @user.community_user)
if current_user.is_global_moderator || current_user.is_global_admin
@warnings = @warnings.or ModWarning.where(user: @user, is_global: true)
end
@warnings = @warnings.all
@warnings = @warnings.map { |w| { type: :warning, value: w } }

@messages = ThreadFollower.where(user: @user).all.map { |t| t.id - 1 }
@messages = CommentThread.where(post: nil, is_private: true, id: @messages).all
@messages = @messages.filter { |m| m.comments.first.user&.id != @user&.id }
@messages = @messages.map { |m| { type: :message, value: m } }

print "#{'*' * 50}\n"
print @messages
print "\n#{'*' * 50}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: debug code? Can be removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied on my fork and since merged in to this branch.


@entries = @warnings + @messages
@entries = @entries.sort_by { |e| e[:value].created_at }.reverse
render layout: 'without_sidebar'
end

Expand All @@ -44,25 +62,65 @@ def create

@warning = ModWarning.new(author: current_user, community_user: @user.community_user,
body: params[:mod_warning][:body], is_suspension: is_suspension,
suspension_end: suspension_end, active: true, read: false)
suspension_end: suspension_end, active: true, read: false,
is_global: false)
if @warning.save
if is_suspension
@user.community_user.update(is_suspended: is_suspension, suspension_end: suspension_end,
suspension_public_comment: params[:mod_warning][:suspension_public_notice])
end

redirect_to user_path(@user)
redirect_to mod_user_path(@user)
else
render :new
end
end

def new_global
@warning = ModWarning.new(author: current_user, is_suspension: true)
render layout: 'without_sidebar'
end

def create_global
suspension_duration = params[:mod_warning][:suspension_duration].to_i

suspension_duration = 1 if suspension_duration <= 0
suspension_duration = 7300 if suspension_duration > 7300

suspension_end = DateTime.now + suspension_duration.days

@warning = ModWarning.new(author: current_user, user: @user,
body: params[:mod_warning][:body], is_suspension: true,
suspension_end: suspension_end, active: true, read: false,
is_global: true)
if @warning.save
@user.update(is_globally_suspended: true, global_suspension_end: suspension_end)

redirect_to mod_user_path(@user)
else
render :new
end
end

def lift
@warning = ModWarning.where(community_user: @user.community_user, active: true).last
@warning = ModWarning.where(user: @user, is_global: true, active: true).last
@warning ||= ModWarning.where(community_user: @user.community_user, active: true).last
return not_found if @warning.nil?

if @warning.is_global && !current_user.is_global_moderator && !current_user.is_global_admin
flash[:error] = 'A network-wide suspension has been applied which may only be lifted ' \
'by global moderators. Community-wide suspensions which have been imposed ' \
'before that global suspensions cannot be lifted at this time (which is ' \
'probably, why you are seeing this error).'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commas: the comma-search has returned! Don't need this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied on my fork and since merged in to this branch.

redirect_to mod_warning_log_path(@user)
end

@warning.update(active: false, read: false)
@user.community_user.update is_suspended: false, suspension_public_comment: nil, suspension_end: nil
if @warning.is_global
@user.update is_globally_suspended: false, global_suspension_end: nil
else
@user.community_user.update is_suspended: false, suspension_public_comment: nil, suspension_end: nil
end

AuditLog.moderator_audit(event_type: 'warning_lift', related: @warning, user: current_user,
comment: "<<Warning #{@warning.attributes_print} >>")
Expand All @@ -75,7 +133,8 @@ def lift
private

def set_warning
@warning = ModWarning.where(community_user: current_user.community_user, active: true).last
@warning = ModWarning.where(user: current_user, active: true, is_global: true).last
@warning ||= ModWarning.where(community_user: current_user.community_user, active: true).last
not_found if @warning.nil?
end

Expand Down
1 change: 1 addition & 0 deletions app/controllers/moderator_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def user_vote_summary
total: Vote.where(recv_user: @user).count
)
)
render layout: 'without_sidebar'
end

private
Expand Down
Loading