Skip to content

enhance: allow admins to enforce public user activity - #40002

Open
SHIVANSHGARG07 wants to merge 8 commits into
go-gitea:mainfrom
SHIVANSHGARG07:feat/disable-activity-visibility
Open

SHIVANSHGARG07 wants to merge 8 commits into
go-gitea:mainfrom
SHIVANSHGARG07:feat/disable-activity-visibility

Conversation

@SHIVANSHGARG07

@SHIVANSHGARG07 SHIVANSHGARG07 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Adds a change_activity_visibility option to USER_DISABLED_FEATURES / EXTERNAL_USER_DISABLE_FEATURES so admins can enforce public user activity, e.g. for company instances that require it.

When set, the "Hide Activity" checkbox is locked and every user's activity is treated as public, including users who had hidden it before. The stored preference is kept, so it applies again if the option is removed. The API settings endpoint rejects hiding activity (and changing a locked full name, which was previously unguarded).

Fixes #37961

Screenshots

Before

Before

After

after

Config used

[admin]
USER_DISABLED_FEATURES = change_activity_visibility

Adds a new USER_DISABLED_FEATURES option (change_activity_visibility)
so admins can lock the 'Hide Activity from profile page' checkbox,
mirroring the existing change_username/change_full_name guards.

Fixes: go-gitea#37961
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 24, 2026
@github-actions github-actions Bot added the type/enhancement An improvement of existing functionality label Oct 24, 2026
@SHIVANSHGARG07

Copy link
Copy Markdown
Contributor Author

Hello @maintainers can you please review this.

@SHIVANSHGARG07
SHIVANSHGARG07 requested a review from lunny October 31, 2026 13:40
@lunny
lunny requested a balanced review from Copilot October 31, 2026 18:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 31, 2026
@SHIVANSHGARG07
SHIVANSHGARG07 requested a review from bircni November 1, 2026 04:32

@bircni bircni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • The API isn't guarded. routers/api/v1/user/settings.go:57 still applies HideActivity from PATCH /user/settings, so any user can bypass the lock through the API.
    • The option isn't documented. custom/conf/app.example.ini:1729-1730 lists change_username and change_full_name but not change_activity_visibility.

--> fixing it

@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 1, 2026
Treat activity as public when admins disable change_activity_visibility,
regardless of a previously stored preference, which is kept so it
applies again if the lock is lifted. Also guard the API settings
endpoint and document the option.

Assisted-by: Claude Code:claude-opus-5-5
Return 403 from PATCH /user/settings when the change is locked, explain
the disabled checkbox in the UI and skip the activity SQL filter when
everyone is forced public.

Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5
@github-actions github-actions Bot added the docs-update-needed The document needs to be updated synchronously label Nov 1, 2026
@SHIVANSHGARG07
SHIVANSHGARG07 requested a review from delvh November 1, 2026 09:21
@bircni

bircni commented Nov 1, 2026

Copy link
Copy Markdown
Member

Pushed a few follow-ups on top:

  • Locking change_activity_visibility now enforces public activity for everyone, including users who had hidden it before. The stored preference is kept and applies again if the lock is lifted.
  • Feeds, heatmaps, profile/settings pages and the API settings response use the effective value; the SQL filter handles NULL login_type and is skipped when everyone is forced public.
  • PATCH /api/v1/user/settings returns 404 when trying to hide activity or change the full name while locked (the latter was previously unguarded), consistent with other disabled-feature API guards.
  • The disabled checkbox now shows a hint explaining the admin lock.
  • Documented change_activity_visibility (and the missing change_username/change_full_name) in app.example.ini.
  • Tests cover a previously-hidden user becoming public, the stored preference being kept, and the API guards.

Assisted by Claude Code (claude-opus-5-5)

@bircni
bircni requested review from lunny and silverwind November 1, 2026 09:25

@bircni bircni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm now - pls also update the docs repo

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Nov 1, 2026
@bircni bircni changed the title enhance: allow admins to disable user activity visibility toggle enhance: allow admins to enforce public user activity Nov 1, 2026
…ty-visibility

# Conflicts:
#	tests/integration/api_user_update_test.go
Assisted-by: Augment Code:Claude Sonnet 4.5
@SHIVANSHGARG07

Copy link
Copy Markdown
Contributor Author

lgtm now - pls also update the docs repo

Done https://gitea.com/gitea/docs/pulls/624

Comment thread custom/conf/app.example.ini Outdated
;; - manage_credentials: a user cannot configure emails, passwords, or openid
;; - change_username: a user cannot change their username
;; - change_full_name: a user cannot change their full name
;; - change_activity_visibility: a user cannot hide their activity, existing hidden activity becomes public

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's really a strange design that "disabling change_activity_visibility" means "force public".

And future developers need to keep remembering that KeepActivityPrivate / keep_activity_private should never be used. It is very fragile.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe you need to think more about design.

For example: there is "repo force private", then

@wxiaoguang
wxiaoguang marked this pull request as draft November 1, 2026 10:26

@wxiaoguang wxiaoguang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need a better design

@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 1, 2026
@SHIVANSHGARG07

Copy link
Copy Markdown
Contributor Author

Need a better design

will share one design doc and start working after approved

Assisted-by: Augment Agent: GPT-5.6
@SHIVANSHGARG07
SHIVANSHGARG07 marked this pull request as ready for review November 12, 2026 15:11
@SHIVANSHGARG07

Copy link
Copy Markdown
Contributor Author

I redesigned this PR based on the feedback about change_activity_visibility.

The activity policy is now explicit: [service] FORCE_PUBLIC_ACTIVITY = false. The overloaded USER_DISABLED_FEATURES entry has been removed. KeepActivityPrivate remains the user's stored preference, while IsActivityPrivate() and ActivityPublicCond() calculate effective visibility consistently for profiles, feeds, heatmaps, and APIs.

When force-public mode is enabled, the web/API settings cannot enable private activity, the UI control is disabled, and the stored preference is preserved. Disabling the policy restores the user's previous preference.

I also updated configuration documentation, generated Swagger, unit/integration coverage, and tests for API, UI, activity feeds, heatmaps, and preference restoration. The branch was merged with upstream main normally and pushed in commit c0e7c9275b.

Please review the redesigned architecture and mergeability.

Assisted-by: Augment Agent: GPT-5.6 Luna

@wxiaoguang

wxiaoguang commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor
  1. I believe it needs a string value but not boolean, to make it flexible
  2. I don't think we should take these IsActivityPrivate tricks. You can simply do this:
    • When Gitea web starts, check whether the config value has changed (old value is saved into table app_state)
    • If the config setting changed, update the table to make sure all users are in correct state.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-update-needed The document needs to be updated synchronously lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend user disabled features with activity setting

6 participants