API Reference
User privacy settings module for activity visibility control.
This module provides CRUD operations and data models for user privacy settings including activity visibility levels and various data hiding options for activities.
Exports
- CRUD: get_user_privacy_settings_by_user_id, create_user_privacy_settings, edit_user_privacy_settings
- Schemas: UsersPrivacySettingsBase, UsersPrivacySettingsCreate, UsersPrivacySettingsRead, UsersPrivacySettingsUpdate
- Models: UsersPrivacySettings (ORM model)
- Enums: ActivityVisibility
ActivityVisibility
Bases: Enum
Activity visibility levels.
Attributes:
| Name | Type | Description |
|---|---|---|
PUBLIC |
Visible to everyone. |
|
FOLLOWERS |
Visible only to followers. |
|
PRIVATE |
Visible only to the user. |
Source code in backend/app/users/users_privacy_settings/schema.py
13 14 15 16 17 18 19 20 21 22 23 24 25 | |
UsersPrivacySettingsBase
Bases: BaseModel
Base schema for user privacy settings.
Attributes:
| Name | Type | Description |
|---|---|---|
default_activity_visibility |
ActivityVisibility | None
|
Default activity visibility level. |
hide_activity_start_time |
StrictBool | None
|
Hide start time from activities. |
hide_activity_location |
StrictBool | None
|
Hide location data from activities. |
hide_activity_map |
StrictBool | None
|
Hide map visualization from activities. |
hide_activity_hr |
StrictBool | None
|
Hide heart rate data from activities. |
hide_activity_power |
StrictBool | None
|
Hide power data from activities. |
hide_activity_cadence |
StrictBool | None
|
Hide cadence data from activities. |
hide_activity_elevation |
StrictBool | None
|
Hide elevation data from activities. |
hide_activity_speed |
StrictBool | None
|
Hide speed data from activities. |
hide_activity_pace |
StrictBool | None
|
Hide pace data from activities. |
hide_activity_laps |
StrictBool | None
|
Hide lap data from activities. |
hide_activity_workout_sets_steps |
StrictBool | None
|
Hide workout sets and steps from activities. |
hide_activity_gear |
StrictBool | None
|
Hide gear information from activities. |
Source code in backend/app/users/users_privacy_settings/schema.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
UsersPrivacySettingsCreate
Bases: UsersPrivacySettingsBase
Pydantic model for creating user privacy settings.
Inherits all attributes from UsersPrivacySettingsBase.
Source code in backend/app/users/users_privacy_settings/schema.py
105 106 107 108 109 110 | |
UsersPrivacySettingsModel
Bases: Base
User privacy settings for activity visibility control.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
Mapped[int]
|
Primary key. |
user_id |
Mapped[int]
|
Foreign key to users table (unique). |
default_activity_visibility |
Mapped[str]
|
Default visibility level (public, followers, private). |
hide_activity_start_time |
Mapped[bool]
|
Hide activity start time. |
hide_activity_location |
Mapped[bool]
|
Hide activity location. |
hide_activity_map |
Mapped[bool]
|
Hide activity map. |
hide_activity_hr |
Mapped[bool]
|
Hide activity heart rate. |
hide_activity_power |
Mapped[bool]
|
Hide activity power. |
hide_activity_cadence |
Mapped[bool]
|
Hide activity cadence. |
hide_activity_elevation |
Mapped[bool]
|
Hide activity elevation. |
hide_activity_speed |
Mapped[bool]
|
Hide activity speed. |
hide_activity_pace |
Mapped[bool]
|
Hide activity pace. |
hide_activity_laps |
Mapped[bool]
|
Hide activity laps. |
hide_activity_workout_sets_steps |
Mapped[bool]
|
Hide activity workout sets and steps. |
hide_activity_gear |
Mapped[bool]
|
Hide activity gear. |
user |
Mapped[bool]
|
Relationship to Users model. |
Source code in backend/app/users/users_privacy_settings/models.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
UsersPrivacySettingsRead
Bases: UsersPrivacySettingsBase
Schema for reading user privacy settings.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
StrictInt
|
Unique identifier for the privacy settings record. |
user_id |
StrictInt
|
Foreign key reference to the user. |
Source code in backend/app/users/users_privacy_settings/schema.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
UsersPrivacySettingsUpdate
Bases: UsersPrivacySettingsBase
Schema for updating user privacy settings.
Inherits all validation from UsersPrivacySettingsBase. All fields are optional for partial updates.
Source code in backend/app/users/users_privacy_settings/schema.py
113 114 115 116 117 118 119 | |
create_user_privacy_settings
create_user_privacy_settings(user_id, db)
Create privacy settings for a user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
The ID of the user to create settings for. |
required |
db
|
Session
|
SQLAlchemy database session. |
required |
Returns:
| Type | Description |
|---|---|
UsersPrivacySettings
|
The created UsersPrivacySettings model. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
409 error if settings already exist. |
HTTPException
|
500 error if database operation fails. |
Source code in backend/app/users/users_privacy_settings/crud.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
edit_user_privacy_settings
edit_user_privacy_settings(user_id, user_privacy_settings_data, db)
Update privacy settings for a specific user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
The ID of the user to update settings for. |
required |
user_privacy_settings_data
|
UsersPrivacySettingsUpdate
|
Schema with fields to update. |
required |
db
|
Session
|
SQLAlchemy database session. |
required |
Returns:
| Type | Description |
|---|---|
UsersPrivacySettings
|
The updated UsersPrivacySettings model. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
404 error if settings not found. |
HTTPException
|
500 error if database operation fails. |
Source code in backend/app/users/users_privacy_settings/crud.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
get_user_privacy_settings_by_user_id
get_user_privacy_settings_by_user_id(user_id, db)
Retrieve privacy settings for a specific user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
The ID of the user to fetch settings for. |
required |
db
|
Session
|
SQLAlchemy database session. |
required |
Returns:
| Type | Description |
|---|---|
UsersPrivacySettings | None
|
The UsersPrivacySettings model if found, None otherwise. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
500 error if database query fails. |
Source code in backend/app/users/users_privacy_settings/crud.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |