feat: complete profile update and settings management
refactor: change profile update endpoints to PUT refactor: changed profile settings update query to use username chore: update SQL queries for profile operations
This commit is contained in:
@@ -1020,21 +1020,23 @@ func (q *Queries) UpdateProfileByUsername(ctx context.Context, arg UpdateProfile
|
||||
return err
|
||||
}
|
||||
|
||||
const updateProfileSettings = `-- name: UpdateProfileSettings :exec
|
||||
UPDATE profile_settings
|
||||
const updateProfileSettingsByUsername = `-- name: UpdateProfileSettingsByUsername :exec
|
||||
UPDATE profile_settings ps
|
||||
SET
|
||||
hide_fulfilled = COALESCE($2, hide_fulfilled),
|
||||
hide_profile_details = COALESCE($3, hide_profile_details),
|
||||
hide_for_unauthenticated = COALESCE($4, hide_for_unauthenticated),
|
||||
hide_birthday = COALESCE($5, hide_birthday),
|
||||
hide_dates = COALESCE($6, hide_dates),
|
||||
captcha = COALESCE($7, captcha),
|
||||
followers_only_interaction = COALESCE($8, followers_only_interaction)
|
||||
WHERE id = $1
|
||||
hide_fulfilled = COALESCE($2, ps.hide_fulfilled),
|
||||
hide_profile_details = COALESCE($3, ps.hide_profile_details),
|
||||
hide_for_unauthenticated = COALESCE($4, ps.hide_for_unauthenticated),
|
||||
hide_birthday = COALESCE($5, ps.hide_birthday),
|
||||
hide_dates = COALESCE($6, ps.hide_dates),
|
||||
captcha = COALESCE($7, ps.captcha),
|
||||
followers_only_interaction = COALESCE($8, ps.followers_only_interaction)
|
||||
FROM profiles p
|
||||
JOIN users u ON p.user_id = u.id
|
||||
WHERE ps.profile_id = p.id AND u.username = $1
|
||||
`
|
||||
|
||||
type UpdateProfileSettingsParams struct {
|
||||
ID int64
|
||||
type UpdateProfileSettingsByUsernameParams struct {
|
||||
Username string
|
||||
HideFulfilled bool
|
||||
HideProfileDetails bool
|
||||
HideForUnauthenticated bool
|
||||
@@ -1044,9 +1046,9 @@ type UpdateProfileSettingsParams struct {
|
||||
FollowersOnlyInteraction bool
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateProfileSettings(ctx context.Context, arg UpdateProfileSettingsParams) error {
|
||||
_, err := q.db.Exec(ctx, updateProfileSettings,
|
||||
arg.ID,
|
||||
func (q *Queries) UpdateProfileSettingsByUsername(ctx context.Context, arg UpdateProfileSettingsByUsernameParams) error {
|
||||
_, err := q.db.Exec(ctx, updateProfileSettingsByUsername,
|
||||
arg.Username,
|
||||
arg.HideFulfilled,
|
||||
arg.HideProfileDetails,
|
||||
arg.HideForUnauthenticated,
|
||||
|
||||
Reference in New Issue
Block a user