Skip to content

A platform for community discussion. Free, open, simple.

DEV: Clean up user menu notification serialization

Régis Hanolcd11824f0708
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 127ff99465a..ff3b6828b99 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -2038,12 +2038,7 @@ class UsersController < ApplicationController
if reminder_notifications.present?
Notification.populate_acting_user(reminder_notifications)
- serialized_notifications =
- ActiveModel::ArraySerializer.new(
- reminder_notifications,
- each_serializer: NotificationSerializer,
- scope: guardian,
- )
+ serialized_notifications = serialize_data(reminder_notifications, NotificationSerializer)
end
if bookmark_list
@@ -2111,23 +2106,13 @@ class UsersController < ApplicationController
Notification.populate_acting_user(notifications) if notifications.present?
if unread_notifications.present?
- serialized_unread_notifications =
- ActiveModel::ArraySerializer.new(
- unread_notifications,
- each_serializer: NotificationSerializer,
- scope: guardian,
- )
+ serialized_unread_notifications = serialize_data(unread_notifications, NotificationSerializer)
end
serialized_messages = serialize_data(messages, UserMenuMessageSerializer) if messages
if read_notifications.present?
- serialized_read_notifications =
- ActiveModel::ArraySerializer.new(
- read_notifications,
- each_serializer: NotificationSerializer,
- scope: guardian,
- )
+ serialized_read_notifications = serialize_data(read_notifications, NotificationSerializer)
end
render json: {
diff --git a/frontend/discourse/app/lib/plugin-api.gjs b/frontend/discourse/app/lib/plugin-api.gjs
index 6d7ba7fe4f9..b243448b5e6 100644
--- a/frontend/discourse/app/lib/plugin-api.gjs
+++ b/frontend/discourse/app/lib/plugin-api.gjs
@@ -3337,10 +3337,7 @@ class _PluginApi {
* ```
* api.registerModelTransformer("topic", async (topics) => {
* for (const topic of topics) {
- * const decryptedTitle = await decryptTitle(topic.encrypted_title);
- * if (decryptedTitle) {
- * topic.fancy_title = decryptedTitle;
- * }
+ * topic.fancy_title = await translateTitle(topic.fancy_title);
* }
* });
* ```