Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions backend/models/dtos/user_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class UserDTO(BaseModel):
)
projects_notifications: bool = Field(None, alias="projectsNotifications")
tasks_notifications: bool = Field(None, alias="tasksNotifications")
task_validation_notification: bool = Field(None, alias="taskValidationNotification")
task_invalidation_notification: bool = Field(
None, alias="taskInvalidationNotification"
)
tasks_comments_notifications: bool = Field(None, alias="taskCommentsNotifications")
teams_announcement_notifications: bool = Field(
None, alias="teamsAnnouncementNotifications"
Expand Down
4 changes: 4 additions & 0 deletions backend/models/postgis/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class User(Base):
projects_comments_notifications = Column(Boolean, default=False, nullable=False)
projects_notifications = Column(Boolean, default=True, nullable=False)
tasks_notifications = Column(Boolean, default=True, nullable=False)
task_validation_notification = Column(Boolean, default=True, nullable=False)
task_invalidation_notification = Column(Boolean, default=True, nullable=False)
tasks_comments_notifications = Column(Boolean, default=False, nullable=False)
teams_announcement_notifications = Column(Boolean, default=True, nullable=False)
date_registered = Column(DateTime, default=timestamp)
Expand Down Expand Up @@ -503,6 +505,8 @@ async def as_dto(self, logged_in_username: str, db: Database) -> UserDTO:
user_dto.projects_notifications = self.projects_notifications
user_dto.projects_comments_notifications = self.projects_comments_notifications
user_dto.tasks_notifications = self.tasks_notifications
user_dto.task_validation_notification = self.task_validation_notification
user_dto.task_invalidation_notification = self.task_invalidation_notification
user_dto.tasks_comments_notifications = self.tasks_comments_notifications
user_dto.teams_announcement_notifications = (
self.teams_announcement_notifications
Expand Down
12 changes: 8 additions & 4 deletions backend/services/messaging/message_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,16 @@ async def _push_messages(messages: list, db: Database):
and obj.message_type == MessageType.TASK_COMMENT_NOTIFICATION.value
):
continue
if (
user.task_validation_notification is False
and obj.message_type == MessageType.VALIDATION_NOTIFICATION.value
):
continue

if user.tasks_notifications is False and obj.message_type in (
MessageType.VALIDATION_NOTIFICATION.value,
MessageType.INVALIDATION_NOTIFICATION.value,
if (
user.task_invalidation_notification is False
and obj.message_type == MessageType.INVALIDATION_NOTIFICATION.value
):
messages_objs.append(obj)
continue
# If the notification is enabled, send an email
messages_objs.append(obj)
Expand Down
2 changes: 2 additions & 0 deletions backend/services/users/user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ async def register_user(osm_id, username, changeset_count, picture_url, email, d
"projects_comments_notifications": False,
"projects_notifications": True,
"tasks_notifications": True,
"task_validation_notification": True,
"task_invalidation_notification": True,
"tasks_comments_notifications": False,
"teams_announcement_notifications": True,
"date_registered": datetime.datetime.utcnow(),
Expand Down
12 changes: 9 additions & 3 deletions frontend/src/components/user/forms/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ export function UserNotificationsForm(props) {
default: false,
},
{
labelId: 'taskUpdates',
descriptionId: 'taskUpdatesDescription',
fieldName: 'tasksNotifications',
labelId: 'taskValidationUpdates',
descriptionId: 'taskValidationUpdatesDescription',
fieldName: 'taskValidationNotification',
default: true,
},
{
labelId: 'taskInvalidationUpdates',
descriptionId: 'taskInvalidationUpdatesDescription',
fieldName: 'taskInvalidationNotification',
default: true,
},
{
Expand Down
18 changes: 13 additions & 5 deletions frontend/src/components/user/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,13 @@ export default defineMessages({
id: 'user.notifications.projects',
defaultMessage: 'Project updates',
},
taskUpdates: {
id: 'user.notifications.tasks',
defaultMessage: 'Tasks validation emails',
taskValidationUpdates: {
id: 'user.notifications.tasks.validation',
defaultMessage: 'Task validation emails',
},
taskInvalidationUpdates: {
id: 'user.notifications.tasks.invalidation',
defaultMessage: 'Task invalidation emails',
},
required: {
id: 'user.settings.required',
Expand All @@ -158,10 +162,14 @@ export default defineMessages({
id: 'user.notifications.projects.description',
defaultMessage: 'You get a notification when a project you have contributed to makes progress.',
},
taskUpdatesDescription: {
id: 'user.notifications.task.description',
taskValidationUpdatesDescription: {
id: 'user.notifications.task.validation.description',
defaultMessage: 'Receive an email when a task you have contributed to is validated.',
},
taskInvalidationUpdatesDescription: {
id: 'user.notifications.task.invalidation.description',
defaultMessage: 'Receive an email when a task you have contributed to is invalidated.',
},
questionsAndComments: {
id: 'user.notifications.questionsAndComments',
defaultMessage: 'Questions and comments',
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/network/tests/mockData/userList.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export const userQueryDetails = {
mentionsNotifications: true,
questionsAndCommentsNotifications: true,
projectsNotifications: true,
tasksNotifications: true,
taskValidationNotification: true,
taskInvalidationNotification: true,
taskCommentsNotifications: true,
teamsAnnouncementNotifications: false,
gender: 'MALE',
Expand Down
42 changes: 42 additions & 0 deletions migrations/versions/a1b2c3d4e5f6_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""Split tasks_notifications into task_validation_notification and task_invalidation_notification

Revision ID: a1b2c3d4e5f6
Revises: b720f42ce3e8
Create Date: 2026-03-17 10:25:00.000000

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "a1b2c3d4e5f6"
down_revision = "b720f42ce3e8"
branch_labels = None
depends_on = None


def upgrade():
op.add_column(
"users",
sa.Column(
"task_validation_notification",
sa.Boolean(),
nullable=False,
server_default=sa.text("true"),
),
)
op.add_column(
"users",
sa.Column(
"task_invalidation_notification",
sa.Boolean(),
nullable=False,
server_default=sa.text("true"),
),
)


def downgrade():
op.drop_column("users", "task_validation_notification")
op.drop_column("users", "task_invalidation_notification")
6 changes: 6 additions & 0 deletions tests/api/helpers/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ async def return_canned_user(db, username=TEST_USERNAME, id=TEST_USER_ID) -> Use
test_user.projects_comments_notifications = False
test_user.projects_notifications = True
test_user.tasks_notifications = True
test_user.task_validation_notification = True
test_user.task_invalidation_notification = True
test_user.tasks_comments_notifications = False
test_user.teams_announcement_notifications = True
test_user.date_registered = datetime.utcnow()
Expand Down Expand Up @@ -281,13 +283,15 @@ async def create_canned_user(db, test_user=None):
id, username, role, mapping_level, tasks_mapped, tasks_validated, tasks_invalidated,
email_address, is_email_verified, is_expert, default_editor, mentions_notifications,
projects_comments_notifications, projects_notifications, tasks_notifications,
task_validation_notification, task_invalidation_notification,
tasks_comments_notifications, teams_announcement_notifications, date_registered,
last_validation_date
)
VALUES (
:id, :username, :role, :mapping_level, :tasks_mapped, :tasks_validated, :tasks_invalidated,
:email_address, :is_email_verified, :is_expert, :default_editor, :mentions_notifications,
:projects_comments_notifications, :projects_notifications, :tasks_notifications,
:task_validation_notification, :task_invalidation_notification,
:tasks_comments_notifications, :teams_announcement_notifications, :date_registered,
:last_validation_date
)
Expand All @@ -308,6 +312,8 @@ async def create_canned_user(db, test_user=None):
"projects_comments_notifications": test_user.projects_comments_notifications,
"projects_notifications": test_user.projects_notifications,
"tasks_notifications": test_user.tasks_notifications,
"task_validation_notification": test_user.task_validation_notification,
"task_invalidation_notification": test_user.task_invalidation_notification,
"tasks_comments_notifications": test_user.tasks_comments_notifications,
"teams_announcement_notifications": test_user.teams_announcement_notifications,
"date_registered": test_user.date_registered,
Expand Down
4 changes: 4 additions & 0 deletions tests/api/unit/models/postgis/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ async def setup_test_data(self, db_connection_fixture, request):
"projects_comments_notifications": False,
"projects_notifications": True,
"tasks_notifications": True,
"task_validation_notification": True,
"task_invalidation_notification": True,
"tasks_comments_notifications": False,
"teams_announcement_notifications": True,
}
Expand All @@ -42,6 +44,7 @@ async def setup_test_data(self, db_connection_fixture, request):
is_email_verified, is_expert, default_editor,
mentions_notifications, projects_comments_notifications,
projects_notifications, tasks_notifications,
task_validation_notification, task_invalidation_notification,
tasks_comments_notifications, teams_announcement_notifications
)
VALUES (
Expand All @@ -50,6 +53,7 @@ async def setup_test_data(self, db_connection_fixture, request):
:is_email_verified, :is_expert, :default_editor,
:mentions_notifications, :projects_comments_notifications,
:projects_notifications, :tasks_notifications,
:task_validation_notification, :task_invalidation_notification,
:tasks_comments_notifications, :teams_announcement_notifications
)
ON CONFLICT (id) DO NOTHING
Expand Down
Loading