Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

Verify is now Trust. Also some minor UI changes.

Matt Roberts8f744054f8f5
diff --git a/app/cmd/routes.go b/app/cmd/routes.go
index 5ad04a9c6..78a39fc12 100644
--- a/app/cmd/routes.go
+++ b/app/cmd/routes.go
@@ -160,7 +160,7 @@ func routes(r *web.Engine) *web.Engine {
ui.Get("/admin/advanced", handlers.AdvancedSettingsPage())
ui.Get("/admin/privacy", handlers.Page("Privacy · Site Settings", "", "Administration/pages/PrivacySettings.page"))
ui.Get("/admin/invitations", handlers.Page("Invitations · Site Settings", "", "Administration/pages/Invitations.page"))
- ui.Get("/admin/members", handlers.ManageMembers())
+ ui.Get("/admin/users", handlers.ManageMembers())
ui.Get("/admin/tags", handlers.ManageTags())
ui.Get("/admin/moderation", handlers.GetModerationPageHandler())
ui.Get("/admin/authentication", handlers.ManageAuthentication())
@@ -188,8 +188,8 @@ func routes(r *web.Engine) *web.Engine {
ui.Post("/_api/admin/roles/:role/users", handlers.ChangeUserRole())
ui.Put("/_api/admin/users/:userID/block", handlers.BlockUser())
ui.Delete("/_api/admin/users/:userID/block", handlers.UnblockUser())
- ui.Put("/_api/admin/users/:userID/verify", handlers.VerifyUser())
- ui.Delete("/_api/admin/users/:userID/verify", handlers.UnverifyUser())
+ ui.Put("/_api/admin/users/:userID/trust", handlers.TrustUser())
+ ui.Delete("/_api/admin/users/:userID/trust", handlers.UntrustUser())
ui.Get("/_api/admin/moderation/items", handlers.GetModerationItemsHandler())
ui.Get("/_api/admin/moderation/count", handlers.GetModerationCountHandler())
diff --git a/app/handlers/user.go b/app/handlers/user.go
index 05ea0aa9e..dedd1064a 100644
--- a/app/handlers/user.go
+++ b/app/handlers/user.go
@@ -40,15 +40,15 @@ func UnblockUser() web.HandlerFunc {
}
}
-// VerifyUser is used to verify an existing user
-func VerifyUser() web.HandlerFunc {
+// TrustUser is used to trust an existing user
+func TrustUser() web.HandlerFunc {
return func(c *web.Context) error {
userID, err := c.ParamAsInt("userID")
if err != nil {
return c.NotFound()
}
- err = bus.Dispatch(c, &cmd.VerifyUser{UserID: userID})
+ err = bus.Dispatch(c, &cmd.TrustUser{UserID: userID})
if err != nil {
return c.Failure(err)
}
@@ -57,15 +57,15 @@ func VerifyUser() web.HandlerFunc {
}
}
-// UnverifyUser is used to unverify an existing user
-func UnverifyUser() web.HandlerFunc {
+// UntrustUser is used to untrust an existing user
+func UntrustUser() web.HandlerFunc {
return func(c *web.Context) error {
userID, err := c.ParamAsInt("userID")
if err != nil {
return c.NotFound()
}
- err = bus.Dispatch(c, &cmd.UnverifyUser{UserID: userID})
+ err = bus.Dispatch(c, &cmd.UntrustUser{UserID: userID})
if err != nil {
return c.Failure(err)
}
diff --git a/app/models/cmd/moderation.go b/app/models/cmd/moderation.go
index ea365d36e..4ca5b4083 100644
--- a/app/models/cmd/moderation.go
+++ b/app/models/cmd/moderation.go
@@ -26,6 +26,6 @@ type BulkDeclineItems struct {
CommentIDs []int
}
-type VerifyUser struct {
+type TrustUser struct {
UserID int
}
diff --git a/app/models/cmd/user.go b/app/models/cmd/user.go
index 6dff9853e..81e25f1dd 100644
--- a/app/models/cmd/user.go
+++ b/app/models/cmd/user.go
@@ -14,7 +14,7 @@ type UnblockUser struct {
UserID int
}
-type UnverifyUser struct {
+type UntrustUser struct {
UserID int
}
diff --git a/app/models/entity/user.go b/app/models/entity/user.go
index 017afc1da..0a70c2a38 100644
--- a/app/models/entity/user.go
+++ b/app/models/entity/user.go
@@ -18,7 +18,7 @@ type User struct {
AvatarType enum.AvatarType `json:"-"`
AvatarURL string `json:"avatarURL,omitempty"`
Status enum.UserStatus `json:"status"`
- IsVerified bool `json:"isVerified"`
+ IsTrusted bool `json:"isTrusted"`
}
// HasProvider returns true if current user has registered with given provider
@@ -43,7 +43,7 @@ func (u *User) IsAdministrator() bool {
// RequiresModeration returns true if user requires moderation
func (u *User) RequiresModeration() bool {
- return u.Role == enum.RoleVisitor && !u.IsVerified
+ return u.Role == enum.RoleVisitor && !u.IsTrusted
}
// UserProvider represents the relationship between an User and an Authentication provide
diff --git a/app/models/entity/user_test.go b/app/models/entity/user_test.go
index dfbb48622..bd7d4a58a 100644
--- a/app/models/entity/user_test.go
+++ b/app/models/entity/user_test.go
@@ -21,7 +21,7 @@ func TestUserWithEmail_MarshalJSON(t *testing.T) {
},
}
- expectedJSON := `{"id":1,"name":"John Doe","role":"visitor","status":"active","isVerified":false,"email":"[email protected]"}`
+ expectedJSON := `{"id":1,"name":"John Doe","role":"visitor","status":"active","isTrusted":false,"email":"[email protected]"}`
jsonData, err := json.Marshal(user)
if err != nil {
@@ -43,7 +43,7 @@ func TestUser_MarshalJSON(t *testing.T) {
Status: 1,
}
- expectedJSON := `{"id":1,"name":"John Doe","role":"visitor","status":"active","isVerified":false}`
+ expectedJSON := `{"id":1,"name":"John Doe","role":"visitor","status":"active","isTrusted":false}`
jsonData, err := json.Marshal(user)
if err != nil {
diff --git a/app/pkg/web/renderer.go b/app/pkg/web/renderer.go
index f21191b10..78bd253b5 100644
--- a/app/pkg/web/renderer.go
+++ b/app/pkg/web/renderer.go
@@ -233,7 +233,7 @@ func (r *Renderer) Render(w io.Writer, statusCode int, props Props, ctx *Context
"avatarBlobKey": u.AvatarBlobKey,
"isAdministrator": u.IsAdministrator(),
"isCollaborator": u.IsCollaborator(),
- "isVerified": u.IsVerified,
+ "isTrusted": u.IsTrusted,
}
}
diff --git a/app/pkg/web/testdata/user.html b/app/pkg/web/testdata/user.html
index 805eddac3..354f09fdc 100755
--- a/app/pkg/web/testdata/user.html
+++ b/app/pkg/web/testdata/user.html
@@ -45,7 +45,7 @@
<script id="server-data" type="application/json">
- {"contextID":"CONTEXT_ID","description":"My Page Description","page":"","props":{},"sessionID":"","settings":{"allowAllowedSchemes":true,"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"isCommercialEnabled":true,"locale":"en","localeDirection":"ltr","mode":"multi","oauth":[],"postWithTags":true},"tenant":null,"title":"My Page Title · Fider","user":{"avatarBlobKey":"","avatarType":"gravatar","avatarURL":"https://demo.test.fider.io:3000/static/avatars/gravatar/5/Jon%20Snow","email":"[email protected]","id":5,"isAdministrator":true,"isCollaborator":true,"isVerified":false,"name":"Jon Snow","role":"administrator","status":"active"}}
+ {"contextID":"CONTEXT_ID","description":"My Page Description","page":"","props":{},"sessionID":"","settings":{"allowAllowedSchemes":true,"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"isCommercialEnabled":true,"locale":"en","localeDirection":"ltr","mode":"multi","oauth":[],"postWithTags":true},"tenant":null,"title":"My Page Title · Fider","user":{"avatarBlobKey":"","avatarType":"gravatar","avatarURL":"https://demo.test.fider.io:3000/static/avatars/gravatar/5/Jon%20Snow","email":"[email protected]","id":5,"isAdministrator":true,"isCollaborator":true,"isTrusted":false,"name":"Jon Snow","role":"administrator","status":"active"}}
</script>
diff --git a/app/services/sqlstore/dbEntities/user.go b/app/services/sqlstore/dbEntities/user.go
index 1d32d08b0..b255f3ca5 100644
--- a/app/services/sqlstore/dbEntities/user.go
+++ b/app/services/sqlstore/dbEntities/user.go
@@ -21,7 +21,7 @@ type User struct {
Status sql.NullInt64 `db:"status"`
AvatarType sql.NullInt64 `db:"avatar_type"`
AvatarBlobKey sql.NullString `db:"avatar_bkey"`
- IsVerified sql.NullBool `db:"is_verified"`
+ IsTrusted sql.NullBool `db:"is_trusted"`
Providers []*UserProvider
}
@@ -63,7 +63,7 @@ func (u *User) ToModel(ctx context.Context) *entity.User {
AvatarType: avatarType,
AvatarBlobKey: u.AvatarBlobKey.String,
AvatarURL: avatarURL,
- IsVerified: u.IsVerified.Bool,
+ IsTrusted: u.IsTrusted.Bool,
}
if u.Providers != nil {
diff --git a/app/services/sqlstore/dbEntities/user_test.go b/app/services/sqlstore/dbEntities/user_test.go
index e4ca46f7c..5f6a8ea7b 100644
--- a/app/services/sqlstore/dbEntities/user_test.go
+++ b/app/services/sqlstore/dbEntities/user_test.go
@@ -27,7 +27,7 @@ func TestUserToModel(t *testing.T) {
Status: sql.NullInt64{Int64: int64(enum.UserActive), Valid: true},
AvatarType: sql.NullInt64{Int64: int64(enum.AvatarTypeGravatar), Valid: true},
AvatarBlobKey: sql.NullString{String: "", Valid: true},
- IsVerified: sql.NullBool{Bool: true, Valid: true},
+ IsTrusted: sql.NullBool{Bool: true, Valid: true},
Providers: []*dbEntities.UserProvider{
{
Name: sql.NullString{String: "google", Valid: true},
@@ -64,8 +64,8 @@ func TestUserToModel(t *testing.T) {
t.Errorf("Expected Status Active, got %v", entityUser.Status)
}
- if !entityUser.IsVerified {
- t.Error("Expected IsVerified to be true")
+ if !entityUser.IsTrusted {
+ t.Error("Expected IsTrusted to be true")
}
if len(entityUser.Providers) != 1 {
diff --git a/app/services/sqlstore/postgres/moderation.go b/app/services/sqlstore/postgres/moderation.go
index 7c35daa77..e4a76d3d4 100644
--- a/app/services/sqlstore/postgres/moderation.go
+++ b/app/services/sqlstore/postgres/moderation.go
@@ -44,6 +44,6 @@ func getModerationCount(ctx context.Context, q *query.GetModerationCount) error
return nil
}
-func verifyUser(ctx context.Context, c *cmd.VerifyUser) error {
+func trustUser(ctx context.Context, c *cmd.TrustUser) error {
return errors.New("Content moderation requires commercial license")
}
\ No newline at end of file
diff --git a/app/services/sqlstore/postgres/postgres.go b/app/services/sqlstore/postgres/postgres.go
index f010526e2..964cba5be 100644
--- a/app/services/sqlstore/postgres/postgres.go
+++ b/app/services/sqlstore/postgres/postgres.go
@@ -86,7 +86,7 @@ func (s Service) Init() {
bus.AddHandler(countUsers)
bus.AddHandler(blockUser)
bus.AddHandler(unblockUser)
- bus.AddHandler(unverifyUser)
+ bus.AddHandler(untrustUser)
bus.AddHandler(regenerateAPIKey)
bus.AddHandler(userSubscribedTo)
bus.AddHandler(deleteCurrentUser)
@@ -158,7 +158,7 @@ func (s Service) Init() {
bus.AddHandler(bulkDeclineItems)
bus.AddHandler(getModerationItems)
bus.AddHandler(getModerationCount)
- bus.AddHandler(verifyUser)
+ bus.AddHandler(trustUser)
}
}
diff --git a/app/services/sqlstore/postgres/user.go b/app/services/sqlstore/postgres/user.go
index 8263bb3c7..d765927a5 100644
--- a/app/services/sqlstore/postgres/user.go
+++ b/app/services/sqlstore/postgres/user.go
@@ -54,13 +54,13 @@ func unblockUser(ctx context.Context, c *cmd.UnblockUser) error {
})
}
-func unverifyUser(ctx context.Context, c *cmd.UnverifyUser) error {
+func untrustUser(ctx context.Context, c *cmd.UntrustUser) error {
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
if _, err := trx.Execute(
- "UPDATE users SET is_verified = false WHERE id = $1 AND tenant_id = $2",
+ "UPDATE users SET is_trusted = false WHERE id = $1 AND tenant_id = $2",
c.UserID, tenant.ID,
); err != nil {
- return errors.Wrap(err, "failed to unverify user")
+ return errors.Wrap(err, "failed to untrust user")
}
return nil
})
@@ -370,7 +370,7 @@ func getAllUsersNames(ctx context.Context, q *query.GetAllUsersNames) error {
func queryUser(ctx context.Context, trx *dbx.Trx, filter string, args ...any) (*entity.User, error) {
user := dbEntities.User{}
- sql := fmt.Sprintf("SELECT id, name, email, tenant_id, role, status, avatar_type, avatar_bkey, is_verified FROM users WHERE status != %d AND ", enum.UserDeleted)
+ sql := fmt.Sprintf("SELECT id, name, email, tenant_id, role, status, avatar_type, avatar_bkey, is_trusted FROM users WHERE status != %d AND ", enum.UserDeleted)
err := trx.Get(&user, sql+filter, args...)
if err != nil {
return nil, err
@@ -397,7 +397,7 @@ func searchUsers(ctx context.Context, q *query.SearchUsers) error {
}
baseQuery := `
- SELECT id, name, email, tenant_id, role, status, avatar_type, avatar_bkey, is_verified
+ SELECT id, name, email, tenant_id, role, status, avatar_type, avatar_bkey, is_trusted
FROM users
WHERE tenant_id = $1 AND status != $2
`
diff --git a/commercial/handlers/apiv1/moderation.go b/commercial/handlers/apiv1/moderation.go
index f8c047778..a930ec17c 100644
--- a/commercial/handlers/apiv1/moderation.go
+++ b/commercial/handlers/apiv1/moderation.go
@@ -154,8 +154,8 @@ func ApprovePostAndVerify() web.HandlerFunc {
return c.Failure(err)
}
- // Then verify the user
- if err := bus.Dispatch(c, &cmd.VerifyUser{UserID: getPost.Result.User.ID}); err != nil {
+ // Then trust the user
+ if err := bus.Dispatch(c, &cmd.TrustUser{UserID: getPost.Result.User.ID}); err != nil {
return c.Failure(err)
}
@@ -183,8 +183,8 @@ func ApproveCommentAndVerify() web.HandlerFunc {
return c.Failure(err)
}
- // Then verify the user
- if err := bus.Dispatch(c, &cmd.VerifyUser{UserID: getComment.Result.User.ID}); err != nil {
+ // Then trust the user
+ if err := bus.Dispatch(c, &cmd.TrustUser{UserID: getComment.Result.User.ID}); err != nil {
return c.Failure(err)
}
diff --git a/commercial/pages/Administration/ContentModeration.page.tsx b/commercial/pages/Administration/ContentModeration.page.tsx
index 401d29dd4..706a2519b 100644
--- a/commercial/pages/Administration/ContentModeration.page.tsx
+++ b/commercial/pages/Administration/ContentModeration.page.tsx
@@ -229,7 +229,7 @@ const ContentModerationPage = () => {
>
<Icon sprite={IconShieldCheck} />
<span>
- <Trans id="action.approve.verify">Approve & Verify</Trans>
+ <Trans id="action.approve.verify">Approve & Trust</Trans>
</span>
</Button>
<Button
diff --git a/commercial/services/sqlstore/postgres/moderation.go b/commercial/services/sqlstore/postgres/moderation.go
index 924a3df2f..b72d30380 100644
--- a/commercial/services/sqlstore/postgres/moderation.go
+++ b/commercial/services/sqlstore/postgres/moderation.go
@@ -270,14 +270,14 @@ func GetModerationCount(ctx context.Context, q *query.GetModerationCount) error
})
}
-func VerifyUser(ctx context.Context, c *cmd.VerifyUser) error {
+func TrustUser(ctx context.Context, c *cmd.TrustUser) error {
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
- // Verify and unblock the user (can't be both blocked and verified)
+ // Trust and unblock the user (can't be both blocked and trusted)
_, err := trx.Execute(`
- UPDATE users SET is_verified = true, status = $1
+ UPDATE users SET is_trusted = true, status = $1
WHERE id = $2 AND tenant_id = $3`, enum.UserActive, c.UserID, tenant.ID)
if err != nil {
- return errors.Wrap(err, "failed to verify user")
+ return errors.Wrap(err, "failed to trust user")
}
return nil
diff --git a/commercial/services/sqlstore/postgres/postgres.go b/commercial/services/sqlstore/postgres/postgres.go
index ef7864289..3b88cae41 100644
--- a/commercial/services/sqlstore/postgres/postgres.go
+++ b/commercial/services/sqlstore/postgres/postgres.go
@@ -33,5 +33,5 @@ func (s CommercialService) Init() {
bus.AddHandler(BulkDeclineItems)
bus.AddHandler(GetModerationItems)
bus.AddHandler(GetModerationCount)
- bus.AddHandler(VerifyUser)
+ bus.AddHandler(TrustUser)
}
diff --git a/locale/en/client.json b/locale/en/client.json
index 9d869229d..2395d1158 100644
--- a/locale/en/client.json
+++ b/locale/en/client.json
@@ -1,6 +1,6 @@
{
"action.approve": "Approve",
- "action.approve.verify": "Approve & Verify",
+ "action.approve.verify": "Approve & Trust",
"action.cancel": "Cancel",
"action.change": "change",
"action.close": "Close",
diff --git a/migrations/202511041300_content_moderation.sql b/migrations/202511041300_content_moderation.sql
index 74b2932e5..795cb9179 100644
--- a/migrations/202511041300_content_moderation.sql
+++ b/migrations/202511041300_content_moderation.sql
@@ -49,9 +49,9 @@ BEGIN
END IF;
END $$;
--- Add user verification column to users table
--- This allows users to be verified for automatic approval of their content
-ALTER TABLE users ADD COLUMN IF NOT EXISTS is_verified boolean NOT NULL DEFAULT false;
+-- Add user trust column to users table
+-- This allows users to be trusted for automatic approval of their content
+ALTER TABLE users ADD COLUMN IF NOT EXISTS is_trusted boolean NOT NULL DEFAULT false;
-- Add index for performance
-CREATE INDEX IF NOT EXISTS idx_users_verification ON users(tenant_id, is_verified) WHERE is_verified = true;
\ No newline at end of file
+CREATE INDEX IF NOT EXISTS idx_users_trust ON users(tenant_id, is_trusted) WHERE is_trusted = true;
\ No newline at end of file
diff --git a/public/components/VoteCounter.spec.tsx b/public/components/VoteCounter.spec.tsx
index 51bc1bd4d..5d61559c9 100644
--- a/public/components/VoteCounter.spec.tsx
+++ b/public/components/VoteCounter.spec.tsx
@@ -22,7 +22,7 @@ beforeEach(() => {
user: {
id: 5,
name: "John",
- isVerified: false,
+ isTrusted: false,
role: UserRole.Collaborator,
status: UserStatus.Active,
avatarURL: "/static/avatars/letter/5/John",
diff --git a/public/models/identity.ts b/public/models/identity.ts
index 088f42422..6b6f68063 100644
--- a/public/models/identity.ts
+++ b/public/models/identity.ts
@@ -28,7 +28,7 @@ export interface User {
email?: string
role: UserRole
status: UserStatus
- isVerified: boolean
+ isTrusted: boolean
avatarURL: string
}
@@ -60,7 +60,7 @@ export const isCollaborator = (role: UserRole): boolean => {
}
export const requiresModeration = (user: User): boolean => {
- return user.role === UserRole.Visitor && !user.isVerified
+ return user.role === UserRole.Visitor && !user.isTrusted
}
export interface CurrentUser {
@@ -74,5 +74,5 @@ export interface CurrentUser {
status: UserStatus
isAdministrator: boolean
isCollaborator: boolean
- isVerified: boolean
+ isTrusted: boolean
}
diff --git a/public/pages/Administration/components/SideMenu.tsx b/public/pages/Administration/components/SideMenu.tsx
index b88e7b321..acde6b97c 100644
--- a/public/pages/Administration/components/SideMenu.tsx
+++ b/public/pages/Administration/components/SideMenu.tsx
@@ -42,7 +42,7 @@ export const SideMenu = (props: SiteMenuProps) => {
<VStack spacing={0} className="c-side-menu rounded-md shadow bg-white">
<SideMenuItem name="general" title="General" href="/admin" isActive={activeItem === "general"} />
<SideMenuItem name="privacy" title="Privacy" href="/admin/privacy" isActive={activeItem === "privacy"} />
- <SideMenuItem name="members" title="Members" href="/admin/members" isActive={activeItem === "members"} />
+ <SideMenuItem name="users" title="Users" href="/admin/users" isActive={activeItem === "users"} />
<SideMenuItem name="tags" title="Tags" href="/admin/tags" isActive={activeItem === "tags"} />
<SideMenuItem name="invitations" title="Invitations" href="/admin/invitations" isActive={activeItem === "invitations"} />
<SideMenuItem name="authentication" title="Authentication" href="/admin/authentication" isActive={activeItem === "authentication"} />
diff --git a/public/pages/Administration/pages/ManageMembers.page.tsx b/public/pages/Administration/pages/ManageMembers.page.tsx
index cd82b1dff..7b2020d7b 100644
--- a/public/pages/Administration/pages/ManageMembers.page.tsx
+++ b/public/pages/Administration/pages/ManageMembers.page.tsx
@@ -27,10 +27,10 @@ const UserListItem = (props: UserListItemExtendedProps) => {
const admin = props.user.role === UserRole.Administrator && <span className="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded">administrator</span>
const collaborator = props.user.role === UserRole.Collaborator && <span className="text-xs bg-green-100 text-green-800 px-2 py-1 rounded">collaborator</span>
const blocked = props.user.status === UserStatus.Blocked && <span className="text-xs bg-red-100 text-red-800 px-2 py-1 rounded">blocked</span>
- const verified = props.user.status === UserStatus.Active && props.user.role === UserRole.Visitor && props.user.isVerified && (
- <span className="text-xs bg-green-100 text-green-800 px-2 py-1 rounded">verified visitor</span>
+ const trusted = props.user.status === UserStatus.Active && props.user.role === UserRole.Visitor && props.user.isTrusted && (
+ <span className="text-xs bg-green-100 text-green-800 px-2 py-1 rounded">trusted member</span>
)
- const isVisitor = props.user.role === UserRole.Visitor
+ const isMember = props.user.role === UserRole.Visitor
const actionSelected = (actionName: string) => () => {
props.onAction(actionName, props.user)
@@ -51,23 +51,23 @@ const UserListItem = (props: UserListItemExtendedProps) => {
</div>
<div>
- {admin} {collaborator} {blocked} {verified}
- {isVisitor && !blocked && !verified && <span className="text-xs text-gray-600">visitor</span>}
+ {admin} {collaborator} {blocked} {trusted}
+ {isMember && !blocked && !trusted && <span className="text-xs text-gray-600">member</span>}
</div>
<div className="flex justify-end relative">
{Fider.session.user.id !== props.user.id && Fider.session.user.isAdministrator && (
<div className="relative z-10">
<Dropdown renderHandle={<Icon sprite={IconDotsHorizontal} width="16" height="16" />}>
- {!blocked && (!!collaborator || isVisitor) && (
+ {!blocked && (!!collaborator || isMember) && (
<Dropdown.ListItem onClick={actionSelected("to-administrator")}>Promote to Administrator</Dropdown.ListItem>
)}
- {!blocked && (!!admin || isVisitor) && <Dropdown.ListItem onClick={actionSelected("to-collaborator")}>Promote to Collaborator</Dropdown.ListItem>}
- {!blocked && (!!collaborator || !!admin) && <Dropdown.ListItem onClick={actionSelected("to-visitor")}>Demote to Visitor</Dropdown.ListItem>}
- {isVisitor && !blocked && !props.user.isVerified && <Dropdown.ListItem onClick={actionSelected("approve")}>Verify User</Dropdown.ListItem>}
- {isVisitor && !blocked && props.user.isVerified && <Dropdown.ListItem onClick={actionSelected("unapprove")}>Unverify User</Dropdown.ListItem>}
- {isVisitor && !blocked && <Dropdown.ListItem onClick={actionSelected("block")}>Block User</Dropdown.ListItem>}
- {isVisitor && !!blocked && <Dropdown.ListItem onClick={actionSelected("unblock")}>Unblock User</Dropdown.ListItem>}
+ {!blocked && (!!admin || isMember) && <Dropdown.ListItem onClick={actionSelected("to-collaborator")}>Promote to Collaborator</Dropdown.ListItem>}
+ {!blocked && (!!collaborator || !!admin) && <Dropdown.ListItem onClick={actionSelected("to-visitor")}>Demote to Member</Dropdown.ListItem>}
+ {isMember && !blocked && !props.user.isTrusted && <Dropdown.ListItem onClick={actionSelected("approve")}>Trust User</Dropdown.ListItem>}
+ {isMember && !blocked && props.user.isTrusted && <Dropdown.ListItem onClick={actionSelected("unapprove")}>Untrust User</Dropdown.ListItem>}
+ {isMember && !blocked && <Dropdown.ListItem onClick={actionSelected("block")}>Block User</Dropdown.ListItem>}
+ {isMember && !!blocked && <Dropdown.ListItem onClick={actionSelected("unblock")}>Unblock User</Dropdown.ListItem>}
</Dropdown>
</div>
)}
@@ -184,11 +184,11 @@ export default function ManageMembersPage(props: ManageMembersPageProps) {
}
}
- const changeVerification = async (isVerified: boolean) => {
- const action = isVerified ? actions.verifyUser : actions.unverifyUser
+ const changeTrust = async (isTrusted: boolean) => {
+ const action = isTrusted ? actions.trustUser : actions.untrustUser
const result = await action(user.id)
if (result.ok) {
- user.isVerified = isVerified
+ user.isTrusted = isTrusted
// Update the user in current state without full reload
const updatedUsers = users.map((u) => (u.id === user.id ? user : u))
setUsers(updatedUsers)
@@ -206,9 +206,9 @@ export default function ManageMembersPage(props: ManageMembersPageProps) {
} else if (actionName === "unblock") {
await changeStatus(UserStatus.Active)
} else if (actionName === "approve") {
- await changeVerification(true)
+ await changeTrust(true)
} else if (actionName === "unapprove") {
- await changeVerification(false)
+ await changeTrust(false)
}
},
[users]
@@ -222,7 +222,7 @@ export default function ManageMembersPage(props: ManageMembersPageProps) {
field="query"
icon={query ? IconX : IconSearch}
onIconClick={query ? clearSearch : undefined}
- placeholder="Search for users by name / email ..."
+ placeholder="Search by name / email ..."
value={query}
onChange={handleSearchFilterChanged}
/>
@@ -246,7 +246,7 @@ export default function ManageMembersPage(props: ManageMembersPageProps) {
<span className={roleFilter === UserRole.Collaborator ? "text-semibold" : ""}>Collaborators</span>
</Dropdown.ListItem>
<Dropdown.ListItem onClick={() => handleRoleFilterChanged(UserRole.Visitor)}>
- <span className={roleFilter === UserRole.Visitor ? "text-semibold" : ""}>Visitors</span>
+ <span className={roleFilter === UserRole.Visitor ? "text-semibold" : ""}>Members</span>
</Dropdown.ListItem>
</Dropdown>
</div>
diff --git a/public/pages/DesignSystem/DesignSystem.page.tsx b/public/pages/DesignSystem/DesignSystem.page.tsx
index 1a8448f0f..04581d066 100644
--- a/public/pages/DesignSystem/DesignSystem.page.tsx
+++ b/public/pages/DesignSystem/DesignSystem.page.tsx
@@ -39,7 +39,7 @@ import { useFider } from "@fider/hooks"
const jonSnow: User = {
id: 0,
name: "Jon Snow",
- isVerified: false,
+ isTrusted: false,
role: UserRole.Administrator,
status: UserStatus.Active,
avatarURL:
@@ -50,7 +50,7 @@ const aryaStark: User = {
id: 0,
name: "Arya Snow",
role: UserRole.Visitor,
- isVerified: false,
+ isTrusted: false,
status: UserStatus.Active,
avatarURL: "https://images.unsplash.com/photo-1550525811-e5869dd03032?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80",
}
@@ -58,7 +58,7 @@ const aryaStark: User = {
const robStark: User = {
id: 0,
name: "Robert Stark",
- isVerified: false,
+ isTrusted: false,
role: UserRole.Visitor,
status: UserStatus.Active,
avatarURL:
diff --git a/public/pages/Home/components/ListPosts.tsx b/public/pages/Home/components/ListPosts.tsx
index 341d5ba87..df6f51990 100644
--- a/public/pages/Home/components/ListPosts.tsx
+++ b/public/pages/Home/components/ListPosts.tsx
@@ -3,6 +3,7 @@ import { Post, Tag, CurrentUser } from "@fider/models"
import { ShowTag, VoteCounter, Markdown, Icon, ResponseLozenge } from "@fider/components"
import IconChatAlt2 from "@fider/assets/images/heroicons-chat-alt-2.svg"
import { HStack, VStack } from "@fider/components/layout"
+import { useFider } from "@fider/hooks"
interface ListPostsProps {
posts?: Post[]
@@ -12,6 +13,10 @@ interface ListPostsProps {
}
const ListPostItem = (props: { post: Post; user?: CurrentUser; tags: Tag[] }) => {
+ const fider = useFider()
+ const isModerationEnabled = fider.session.tenant.isModerationEnabled
+ const isPending = isModerationEnabled && !props.post.isApproved
+
return (
<HStack spacing={4} align="start" className="c-posts-container__post">
<div>
@@ -24,9 +29,12 @@ const ListPostItem = (props: { post: Post; user?: CurrentUser; tags: Tag[] }) =>
</div>
)}
<HStack justify="between">
- <a className="text-title text-break hover:text-primary-base" href={`/posts/${props.post.number}/${props.post.slug}`}>
- {props.post.title}
- </a>
+ <HStack spacing={2} align="center">
+ <a className="text-title text-break hover:text-primary-base" href={`/posts/${props.post.number}/${props.post.slug}`}>
+ {props.post.title}
+ </a>
+ {isPending && <span className="text-xs bg-yellow-100 text-yellow-800 px-2 py-1 rounded">pending</span>}
+ </HStack>
{props.post.commentsCount > 0 && (
<HStack className="text-muted">
{props.post.commentsCount} <Icon sprite={IconChatAlt2} className="h-4 ml-1" />
@@ -47,12 +55,19 @@ const ListPostItem = (props: { post: Post; user?: CurrentUser; tags: Tag[] }) =>
}
const MinimalListPostItem = (props: { post: Post; tags: Tag[] }) => {
+ const fider = useFider()
+ const isModerationEnabled = fider.session.tenant.isModerationEnabled
+ const isPending = isModerationEnabled && !props.post.isApproved
+
return (
<HStack spacing={4} align="start" className="c-posts-container__post">
<HStack className="w-full" justify="between" align="start">
- <a className="text-link" href={`/posts/${props.post.number}/${props.post.slug}`}>
- {props.post.title}
- </a>
+ <HStack spacing={2} align="center">
+ <a className="text-link" href={`/posts/${props.post.number}/${props.post.slug}`}>
+ {props.post.title}
+ </a>
+ {isPending && <span className="text-xs bg-yellow-100 text-yellow-800 px-2 py-1 rounded">pending</span>}
+ </HStack>
{props.post.status !== "open" ? (
<div>
<ResponseLozenge status={props.post.status} response={props.post.response} size={"micro"} />
diff --git a/public/services/actions/tenant.ts b/public/services/actions/tenant.ts
index c9332d9fd..17de827ca 100644
--- a/public/services/actions/tenant.ts
+++ b/public/services/actions/tenant.ts
@@ -83,12 +83,12 @@ export const unblockUser = async (userID: number): Promise<Result> => {
return await http.delete(`/_api/admin/users/${userID}/block`)
}
-export const verifyUser = async (userID: number): Promise<Result> => {
- return await http.put(`/_api/admin/users/${userID}/verify`)
+export const trustUser = async (userID: number): Promise<Result> => {
+ return await http.put(`/_api/admin/users/${userID}/trust`)
}
-export const unverifyUser = async (userID: number): Promise<Result> => {
- return await http.delete(`/_api/admin/users/${userID}/verify`)
+export const untrustUser = async (userID: number): Promise<Result> => {
+ return await http.delete(`/_api/admin/users/${userID}/trust`)
}
export const getOAuthConfig = async (provider: string): Promise<Result<OAuthConfig>> => {
diff --git a/public/services/fider.ts b/public/services/fider.ts
index c1c8ac886..2793fa41c 100644
--- a/public/services/fider.ts
+++ b/public/services/fider.ts
@@ -44,7 +44,7 @@ export class FiderSession {
}
public get isModerationRequired(): boolean {
- return this.isCommercialEnabled && this.pTenant.isModerationEnabled && this.isAuthenticated && this.pUser!.role === "visitor" && !this.pUser!.isVerified
+ return this.isCommercialEnabled && this.pTenant.isModerationEnabled && this.isAuthenticated && this.pUser!.role === "visitor" && !this.pUser!.isTrusted
}
public get isCommercialEnabled(): boolean {