From f3109a1f25c52e4bf911ce3bd2854e0de480815d Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Tue, 3 Dec 2019 17:31:16 +1000 Subject: [PATCH] Add timezone to current_user_serializer (#8448) * the code to get current user already got their user_option record as well, so adding the timezone column to the attributes returned should not create any additional overhead. this timezone will be very useful for getting momentjs dates relative to the user's timezone --- app/serializers/current_user_serializer.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rb index 72363fc3ac1..a119bb324a8 100644 --- a/app/serializers/current_user_serializer.rb +++ b/app/serializers/current_user_serializer.rb @@ -44,7 +44,8 @@ class CurrentUserSerializer < BasicUserSerializer :groups, :second_factor_enabled, :ignored_users, - :title_count_mode + :title_count_mode, + :timezone def groups object.visible_groups.pluck(:id, :name).map { |id, name| { id: id, name: name.downcase } } @@ -106,6 +107,10 @@ class CurrentUserSerializer < BasicUserSerializer object.user_option.redirected_to_top end + def timezone + object.user_option.timezone + end + def can_send_private_email_messages scope.can_send_private_messages_to_email? end