Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
462f99f
feat: add UserAnonymityConfig model
IrusHunter May 28, 2026
7dea2b4
add fake username initializers
IrusHunter May 28, 2026
de57609
feat: add anonymity settings and configuration interface
liza-hamai May 29, 2026
bcd6ed8
feat: enhance user and question deletion processes with permanent rem…
IrusHunter May 29, 2026
122130f
feat: refactor settings navigation to enhance user experience and int…
liza-hamai May 29, 2026
d897e45
feat: update user display logic to ensure usernames are shown only wh…
liza-hamai May 29, 2026
95253de
feat: add anonymized responses
IrusHunter May 30, 2026
4d8848d
fix: improve formatting and readability in ActionBar and Comment comp…
liza-hamai May 30, 2026
cb5c40f
Merge branch 'main' of https://github.com/liza-hamai/answer-fork
liza-hamai May 30, 2026
818a0cd
fix: remove debug line
IrusHunter May 30, 2026
3a0ae52
feat: add private level functionality to questions
liza-hamai May 30, 2026
ba8742e
feat: add private level option to question visibility
liza-hamai May 30, 2026
8187960
feat: enhance question visibility and anonymization features
IrusHunter May 31, 2026
56ec1e5
feat: integrate anonymity service for user data anonymization in noti…
IrusHunter Jun 2, 2026
1a76010
add report
IrusHunter Jun 2, 2026
900bb6f
feat: integrate anonymity service into notification handling
liza-hamai Jun 2, 2026
7fbfeed
feat: enhance user info display in notifications
liza-hamai Jun 3, 2026
cd0aec4
fix: remove local work files
IrusHunter Jun 3, 2026
f415de5
chore: add Apache License header to anonymity service files
liza-hamai Jun 3, 2026
d536244
Merge branch 'main' of https://github.com/liza-hamai/answer-fork
liza-hamai Jun 3, 2026
5e8b727
chore: add Apache License header to multiple entity and service files
IrusHunter Jun 3, 2026
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
14 changes: 13 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
],
"explorer.autoReveal": "focusNoScroll",
"cSpell.words": [
"grecaptcha"
"activityqueue",
"answercommon",
"collectioncommon",
"errorlist",
"grecaptcha",
"metacommon",
"noticequeue",
"questioncommon",
"siteinfo",
"tagcommon",
"tagerr",
"taglist",
"usercommon"
]
}
52 changes: 21 additions & 31 deletions cmd/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions i18n/en_US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,7 @@ ui:
notification: Notifications
account: Account
interface: Interface
anonymity: Anonymity
profile:
heading: Profile
btn_name: Save
Expand Down Expand Up @@ -1365,6 +1366,19 @@ ui:
all_new_question_for_following_tags:
label: All new questions for following tags
description: Get notified of new questions for following tags.
anonymity:
heading: Pseudo-Anonymity
intro: >-
When enabled, your questions and answers will be published without
displaying your real username. An alias (pseudonym) will be used instead,
your user ID will be hidden in API responses, and links to your author
profile will be disabled.
turn_on: Turn on
enabled:
label: Enable pseudo-anonymity
description: >-
Publish questions and answers without displaying your real user data.
Uses an alias instead of your username.
account:
heading: Account
change_email_btn: Change email
Expand Down Expand Up @@ -2482,5 +2496,3 @@ ui:
copy: Copy to clipboard
copied: Copied
external_content_warning: External images/media are not displayed.


40 changes: 40 additions & 0 deletions internal/controller/user_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/apache/answer/internal/service/content"
"github.com/apache/answer/internal/service/export"
"github.com/apache/answer/internal/service/siteinfo_common"
"github.com/apache/answer/internal/service/user_anonymity_config"
"github.com/apache/answer/internal/service/user_notification_config"
"github.com/apache/answer/pkg/checker"
"github.com/gin-gonic/gin"
Expand All @@ -50,6 +51,7 @@ type UserController struct {
emailService *export.EmailService
siteInfoCommonService siteinfo_common.SiteInfoCommonService
userNotificationConfigService *user_notification_config.UserNotificationConfigService
userAnonymityConfigService *user_anonymity_config.UserAnonymityConfigService
}

// NewUserController new controller
Expand All @@ -60,6 +62,7 @@ func NewUserController(
emailService *export.EmailService,
siteInfoCommonService siteinfo_common.SiteInfoCommonService,
userNotificationConfigService *user_notification_config.UserNotificationConfigService,
userAnonymityConfigService *user_anonymity_config.UserAnonymityConfigService,
) *UserController {
return &UserController{
authService: authService,
Expand All @@ -68,6 +71,7 @@ func NewUserController(
emailService: emailService,
siteInfoCommonService: siteInfoCommonService,
userNotificationConfigService: userNotificationConfigService,
userAnonymityConfigService: userAnonymityConfigService,
}
}

Expand Down Expand Up @@ -547,6 +551,42 @@ func (uc *UserController) UpdateUserNotificationConfig(ctx *gin.Context) {
handler.HandleResponse(ctx, err, nil)
}

// GetUserAnonymityConfig get user's anonymity config
// @Summary get user's anonymity config
// @Description get user's anonymity config
// @Tags User
// @Accept json
// @Produce json
// @Security ApiKeyAuth
// @Success 200 {object} handler.RespBody{data=schema.GetUserAnonymityConfigResp}
// @Router /answer/api/v1/user/anonymity/config [post]
func (uc *UserController) GetUserAnonymityConfig(ctx *gin.Context) {
userID := middleware.GetLoginUserIDFromContext(ctx)
resp, err := uc.userAnonymityConfigService.GetUserAnonymityConfig(ctx, userID)
handler.HandleResponse(ctx, err, resp)
}

// UpdateUserAnonymityConfig update user's anonymity config
// @Summary update user's anonymity config
// @Description update user's anonymity config
// @Tags User
// @Accept json
// @Produce json
// @Security ApiKeyAuth
// @Param data body schema.UpdateUserAnonymityConfigReq true "UpdateUserAnonymityConfigReq"
// @Success 200 {object} handler.RespBody{}
// @Router /answer/api/v1/user/anonymity/config [put]
func (uc *UserController) UpdateUserAnonymityConfig(ctx *gin.Context) {
req := &schema.UpdateUserAnonymityConfigReq{}
if handler.BindAndCheck(ctx, req) {
return
}

req.UserID = middleware.GetLoginUserIDFromContext(ctx)
err := uc.userAnonymityConfigService.UpdateUserAnonymityConfig(ctx, req)
handler.HandleResponse(ctx, err, nil)
}

// UserChangeEmailSendCode send email to the user email then change their email
// @Summary send email to the user email then change their email
// @Description send email to the user email then change their email
Expand Down
37 changes: 37 additions & 0 deletions internal/entity/fake_username_entity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package entity

import "time"

// FakeUsername fake username
type FakeUsername struct {
ID string `xorm:"pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
UserID string `xorm:"not null default 0 BIGINT(20) user_id"`
QuestionID string `xorm:"not null default 0 BIGINT(20) question_id"`
FakeName string `xorm:"not null VARCHAR(50) fake_name"`
}

// TableName fake username table name
func (FakeUsername) TableName() string {
return "fake_username"
}
5 changes: 5 additions & 0 deletions internal/entity/question_entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ const (
QuestionPin = 2
QuestionShow = 1
QuestionHide = 2

QuestionPrivateLevelPublic = "public"
QuestionPrivateLevelAuthenticated = "authenticated"
QuestionPrivateLevelPrivate = "private"
)

var AdminQuestionSearchStatus = map[string]int{
Expand Down Expand Up @@ -74,6 +78,7 @@ type Question struct {
PostUpdateTime time.Time `xorm:"post_update_time TIMESTAMP"`
RevisionID string `xorm:"not null default 0 BIGINT(20) revision_id"`
LinkedCount int `xorm:"not null default 0 INT(11) linked_count"`
PrivateLevel string `xorm:"not null default 'public' VARCHAR(20) private_level"`
}

// TableName question table name
Expand Down
34 changes: 34 additions & 0 deletions internal/entity/user_anonymity_config_entity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package entity

import "time"

type UserAnonymityConfig struct {
ID string `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
UserID string `xorm:"not null default 0 BIGINT(20) INDEX UNIQUE user_id"`
Enabled bool `xorm:"not null default false BOOL enabled"`
}

func (UserAnonymityConfig) TableName() string {
return "user_anonymity_config"
}
2 changes: 2 additions & 0 deletions internal/migrations/init_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ var (
&entity.APIKey{},
&entity.AIConversation{},
&entity.AIConversationRecord{},
&entity.FakeUsername{},
&entity.UserAnonymityConfig{},
}

roles = []*entity.Role{
Expand Down
Loading