Add creator initials and avatar color to push notification payload

Move avatar_background_color logic from helper to User::Avatar concern
so it can be accessed from models. Include creator_id, creator_initials,
and creator_avatar_color in native push notifications for local avatar
rendering on iOS.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Fernando Olivares
2026-01-25 22:22:25 -06:00
committed by Rosa Gutierrez
parent 113e61d418
commit b1cdb72381
3 changed files with 14 additions and 8 deletions
+1 -8
View File
@@ -1,13 +1,6 @@
require "zlib"
module AvatarsHelper
AVATAR_COLORS = %w[
#AF2E1B #CC6324 #3B4B59 #BFA07A #ED8008 #ED3F1C #BF1B1B #736B1E #D07B53
#736356 #AD1D1D #BF7C2A #C09C6F #698F9C #7C956B #5D618F #3B3633 #67695E
]
def avatar_background_color(user)
AVATAR_COLORS[Zlib.crc32(user.to_param) % AVATAR_COLORS.size]
user.avatar_background_color
end
def avatar_tag(user, hidden_for_screen_reader: false, **options)