Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Remove details from notifications API

Oliver Günther31f9d05552b7
diff --git a/docs/api/apiv3/components/schemas/list_notifications_model.yml b/docs/api/apiv3/components/schemas/list_notifications_model.yml
index fe717d66ce1..b5880c53932 100644
--- a/docs/api/apiv3/components/schemas/list_notifications_model.yml
+++ b/docs/api/apiv3/components/schemas/list_notifications_model.yml
@@ -22,10 +22,6 @@ example:
_type: Notification
createdAt: "2021-07-20T08:32:18Z"
updatedAt: "2021-07-20T08:33:19Z"
- details:
- format: markdown
- raw: "<mention class=\"mention\" data-id=\"90\" data-type=\"user\" data-text=\"@Recipeint User\">@Recipient User</mention> test"
- html: "<p class=\"op-uc-p\"><a class=\"user-mention op-uc-link\" title=\"User Recipient User\" href=\"/users/90\">Recipient User</a> test</p>"
id: 1
reason: mentioned
subject: "You have been mentioned in Task #1234 An important task"
diff --git a/docs/api/apiv3/components/schemas/notification_model.yml b/docs/api/apiv3/components/schemas/notification_model.yml
index 5f52cb478c2..2e9a537fe2e 100644
--- a/docs/api/apiv3/components/schemas/notification_model.yml
+++ b/docs/api/apiv3/components/schemas/notification_model.yml
@@ -12,10 +12,6 @@ properties:
type: string
description: The subject of the notification
readOnly: true
- details:
- type: Array
- description: An array of formattable details
- readOnly: true
reason:
type: string
description: The reason for the notification (such as mentioned, involved, watched)
diff --git a/docs/api/apiv3/tags/notifications.yml b/docs/api/apiv3/tags/notifications.yml
index 5d2bba84772..57e44d9cdc5 100644
--- a/docs/api/apiv3/tags/notifications.yml
+++ b/docs/api/apiv3/tags/notifications.yml
@@ -23,7 +23,6 @@ description: |-
| :----------: | --------------------------------------------------------- | -------- | ---------------------------------------------------- | -------------------- | ----------------------------------------------------------- |
| id | Primary key | Integer | | READ | |
| subject | The subject of the notification | String | | READ | |
- | details | Array of formattable details | []Formattable | | READ | |
| reason | The reason causing the notification | String | | READ | |
| readIAN | Whether the notification is read | Boolean | | READ | |
name: Notifications
diff --git a/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts b/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts
index ed68ee588aa..f3bc3d24d2a 100644
--- a/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts
+++ b/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts
@@ -23,7 +23,6 @@ export interface InAppNotification {
readIAN:boolean|null;
readEmail:boolean|null;
- details?:Formattable[];
// Mark a notification to be kept in the center even though it was saved as "read".
keep?:boolean;
// Show message of a notification?
diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html
index af7b39dc8b8..daa104af2d3 100644
--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html
+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html
@@ -1,6 +1,5 @@
<div
class="op-ian-item--row"
- [class.op-ian-item--row_unexpandable]="unexpandable"
(click)="showDetails()"
>
<ng-container *ngIf="workPackage$ && (workPackage$ | async) as workPackage; else workPackageLoading">
diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts
index 7935aa494b5..d3b0e7f0e6d 100644
--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts
+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts
@@ -1,11 +1,9 @@
import {
ChangeDetectionStrategy,
Component,
- EventEmitter,
HostBinding,
Input,
OnInit,
- Output,
ViewEncapsulation,
} from '@angular/core';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
@@ -27,7 +25,6 @@ import { take } from 'rxjs/internal/operators/take';
import { StateService } from '@uirouter/angular';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { BackRouteOptions } from 'core-app/features/work-packages/components/back-routing/back-routing.service';
-import { Formattable } from 'core-app/core/state/hal-resource';
import { InAppNotification } from 'core-app/core/state/in-app-notifications/in-app-notification.model';
import { IanCenterService } from 'core-app/features/in-app-notifications/center/state/ian-center.service';
@@ -49,15 +46,6 @@ export class InAppNotificationEntryComponent implements OnInit {
loading$ = this.storeService.query.selectLoading();
- // Formattable body, if any
- body:Formattable[];
-
- // custom rendered details, if any
- details:Formattable[];
-
- // Whether body and details are empty
- unexpandable = false;
-
// The actor, if any
actors:PrincipalLike[] = [];
@@ -95,7 +83,6 @@ export class InAppNotificationEntryComponent implements OnInit {
ngOnInit():void {
this.buildTranslatedReason();
this.buildActors();
- this.buildDetails();
this.buildTime();
this.buildProject();
this.loadWorkPackage();
@@ -114,13 +101,6 @@ export class InAppNotificationEntryComponent implements OnInit {
}
}
- private buildDetails() {
- const details = this.notification.details || [];
- this.body = details.filter((el) => el.format === 'markdown');
- this.details = details.filter((el) => el.format === 'custom');
- this.unexpandable = this.body.length === 0 && this.details.length === 0;
- }
-
private buildTime() {
this.fixedTime = this.timezoneService.formattedDatetime(this.notification.createdAt);
this.relativeTime$ = timer(0, 10000)
@@ -133,7 +113,7 @@ export class InAppNotificationEntryComponent implements OnInit {
}
showDetails():void {
- if (this.unexpandable || !this.workPackage$) {
+ if (!this.workPackage$) {
return;
}
diff --git a/lib/api/v3/notifications/notification_representer.rb b/lib/api/v3/notifications/notification_representer.rb
index 901f0a03813..7a6929581bb 100644
--- a/lib/api/v3/notifications/notification_representer.rb
+++ b/lib/api/v3/notifications/notification_representer.rb
@@ -34,9 +34,7 @@ module API
class NotificationRepresenter < ::API::Decorators::Single
include API::Decorators::DateProperty
include API::Decorators::LinkedResource
- include API::Decorators::FormattableProperty
extend API::Decorators::PolymorphicResource
- include API::V3::Activities::ActivityPropertyFormatters
self_link title_getter: ->(*) { represented.subject }
@@ -52,16 +50,6 @@ module API
date_time_property :updated_at
- property :details,
- exec_context: :decorator,
- getter: ->(*) do
- next unless represented.journal
-
- formatted_notification_details(represented.journal)
- .unshift formatted_notes(represented.journal)
- end,
- render_nil: false
-
link :readIAN do
next if represented.read_ian
@@ -99,23 +87,7 @@ module API
'Notification'
end
- self.to_eager_load = [:project,
- :actor,
- { journal: %i[attachable_journals customizable_journals] }]
-
- ##
- # For notifications, we want to skip the initial journal
- # as the information is not that useful
- def formatted_notification_details(journal)
- if journal.initial?
- note_created = I18n.t('notifications.work_packages.subject.created')
- [
- { format: 'custom', raw: note_created, html: "<em>#{note_created}</em>" }
- ]
- else
- formatted_details(journal)
- end
- end
+ self.to_eager_load = %i[project actor]
end
end
end
diff --git a/spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb b/spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb
index dd9367c9df2..4558bcb1aa6 100644
--- a/spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb
@@ -201,26 +201,6 @@ describe ::API::V3::Notifications::NotificationRepresenter, 'rendering' do
.at_path("_embedded/activity/_type")
end
end
-
- it 'renders details of journal' do
- allow(journal).to receive(:initial?).and_return false
-
- expect(generated)
- .to have_json_size(10)
- .at_path('details')
- end
-
- it 'renders a placeholder if journal is initial' do
- allow(journal).to receive(:initial?).and_return true
-
- details = [
- { format: 'markdown', raw: '', html: '' },
- { format: 'custom', raw: "The work package was created.", html: "<em>The work package was created.</em>" }
- ]
- expect(generated)
- .to be_json_eql(details.to_json)
- .at_path('details')
- end
end
end
end