Skip to content

Commit

Permalink
config: allow comment notification builder to be custom
Browse files Browse the repository at this point in the history
  • Loading branch information
carlinmack authored and slint committed Dec 9, 2024
1 parent 115c39d commit 6cf8511
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
7 changes: 5 additions & 2 deletions invenio_requests/customizations/request_types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2022 TU Wien.
# Copyright (C) 2021 CERN.
# Copyright (C) 2021-2022 TU Wien.
# Copyright (C) 2021-2024 CERN.
#
# Invenio-Requests is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -18,6 +18,7 @@
import marshmallow as ma
from invenio_records_resources.services.references import EntityReferenceBaseSchema

from ..notifications.builders import CommentRequestEventCreateNotificationBuilder
from ..proxies import current_requests
from .actions import (
AcceptAction,
Expand Down Expand Up @@ -130,6 +131,8 @@ class RequestType:
}
"""

comment_notification_builder = CommentRequestEventCreateNotificationBuilder

needs_context = None
"""The context for needs.
Expand Down
13 changes: 3 additions & 10 deletions invenio_requests/services/events/service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021-2022 CERN.
# Copyright (C) 2021-2024 CERN.
# Copyright (C) 2021-2022 Northwestern University.
# Copyright (C) 2021-2022 TU Wien.
# Copyright (C) 2023 Graz University of Technology.
Expand All @@ -14,18 +14,11 @@
from invenio_notifications.services.uow import NotificationOp
from invenio_records_resources.services import RecordService, ServiceSchemaWrapper
from invenio_records_resources.services.base.links import LinksTemplate
from invenio_records_resources.services.uow import (
RecordCommitOp,
RecordDeleteOp,
unit_of_work,
)
from invenio_records_resources.services.uow import RecordCommitOp, unit_of_work
from invenio_search.engine import dsl

from invenio_requests.customizations import CommentEventType
from invenio_requests.customizations.event_types import LogEventType
from invenio_requests.notifications.builders import (
CommentRequestEventCreateNotificationBuilder,
)
from invenio_requests.records.api import RequestEventFormat
from invenio_requests.services.results import EntityResolverExpandableField

Expand Down Expand Up @@ -86,7 +79,7 @@ def create(
if notify and event_type is CommentEventType:
uow.register(
NotificationOp(
CommentRequestEventCreateNotificationBuilder.build(request, event)
request.type.comment_notification_builder.build(request, event)
)
)

Expand Down

0 comments on commit 6cf8511

Please sign in to comment.