Skip to content

user emojis#519

Open
mcfiredrill wants to merge 12 commits into
mainfrom
dj-custom-emojis
Open

user emojis#519
mcfiredrill wants to merge 12 commits into
mainfrom
dj-custom-emojis

Conversation

@mcfiredrill
Copy link
Copy Markdown
Member

@mcfiredrill mcfiredrill commented Apr 5, 2026

Adds user emoji support with a model, migration, and API endpoints.

Changes Made

  • Model: UserEmoji with belongs_to :user and has_one_attached :image
  • Migration: Creates user_emojis table with user_id, name, and timestamps
  • API Endpoints:
    • GET /api/user_emojis — lists the current user's emojis
    • POST /api/user_emojis — creates a new user emoji (accepts name and image via JSON:API format)
  • Serializer: UserEmojiSerializer exposing id, name, and image_url
  • User association: Added has_many :user_emojis to the User model

Both API endpoints require authentication.

@mcfiredrill
Copy link
Copy Markdown
Member Author

@copilot create an API endpoint for creating user emojis

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 5, 2026

@copilot create an API endpoint for creating user emojis

Done in commit 2e465c8. Added the following:

  • GET /api/user_emojis — lists the current user's emojis
  • POST /api/user_emojis — creates a new user emoji (accepts name and image via JSON:API format)
  • UserEmojiSerializer returning id, name, and image_url
  • has_many :user_emojis on the User model

Both endpoints require authentication.

@mcfiredrill
Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

Co-authored-by: mcfiredrill <66243+mcfiredrill@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

@copilot resolve the merge conflicts in this pull request

Done in commit 23f7bf3. Merged origin/main into the branch and resolved the single conflict in db/schema.rb — kept the newer schema version (2025_09_20_032802) from main and included the user_accessories and user_live_bars tables that were added there.

def index
@user_emojis = current_user.user_emojis
render json: @user_emojis
end
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this index route quite yet @copilot

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in commit 8f6599e — deleted the index action from the controller and updated the route to only: [:create].

before_action :authenticate_user!

def create
@user_emoji = current_user.user_emojis.new(user_emoji_params)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot You can only create an emoji if you have enough "emoji slots" left.

You get more after leveling up.

Level 3: 1 additional slots granted
Level 4: 2 additional slots granted
Level 5: 2 additional slots granted

(some kind of gentle curve like this, maxing out at level 30 perhaps)

You must also have the DJ role.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot add the code for emoji slots to the user model

we also need to add validations to see if the user is allowed to create more emojis based on their available slots

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot retry

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit ff16a23. Added:

  • User#emoji_slots in User::Rpg: returns 0 for non-DJs or level < 3, then accumulates slots per level using ⌈√(level−2)⌉ — yielding 1 slot at level 3, +2 at level 4, +2 at level 5, growing gently and capping at level 30.
  • UserEmoji validations:
    • User must have the DJ role
    • User must have available emoji slots remaining
  • Specs covering both the slot calculation and the validations.

Copy link
Copy Markdown
Contributor

Copilot AI commented May 3, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • s3.amazonaws.com
    • Triggering command: /usr/bin/ruby3.2 /usr/bin/ruby3.2 -I/usr/lib/ruby/vendor_ruby extconf.rb x86_64-linux-gnu -D _FORTIFY_SOURCE=3 conftest.c -quiet -dumpbase conftest.c -dumpbase-ext .c -I /usr/include/x86/usr/include/ruby-3.2.0/ruby/backward by-3.2.0 s kward y-3.2.0/ruby/bac-I -I y-3.2.0 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Comment thread .bundle/config Outdated
@@ -1,2 +1,3 @@
---
BUNDLE_PATH: "vendor/bundle"
BUNDLE_WITHOUT: "taglib"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this change here ? @copilot

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that was accidentally committed during a local gem install attempt. Removed in commit 7ccc425.

@github-actions
Copy link
Copy Markdown

😰 RSpec failure

185 examples, 8 failures, 49 pending
Example Description Message
spec/models/user_emoji_spec.rb:26 UserEmoji validations when user has the DJ role and has no emoji slots (level < 3) is invalid PG::UndefinedTable: ERROR: relation "user_emojis" does not exist LINE 9: WHERE a.attrelid = '"user_emojis"'::regclass ^
spec/models/user_emoji_spec.rb:35 UserEmoji validations when user has the DJ role and has emoji slots available is valid PG::UndefinedTable: ERROR: relation "user_emojis" does not exist LINE 9: WHERE a.attrelid = '"user_emojis"'::regclass ^
spec/models/user_emoji_spec.rb:43 UserEmoji validations when user has the DJ role and has used all emoji slots is invalid when no slots remain PG::UndefinedTable: ERROR: relation "user_emojis" does not exist LINE 9: WHERE a.attrelid = '"user_emojis"'::regclass ^
spec/models/user_emoji_spec.rb:16 UserEmoji validations when user does not have the DJ role is invalid PG::UndefinedTable: ERROR: relation "user_emojis" does not exist LINE 9: WHERE a.attrelid = '"user_emojis"'::regclass ^
spec/models/user_emoji_spec.rb:75 UserEmoji#emoji_slots returns 5 slots at level 5 undefined method `ceil' for Math:Module
spec/models/user_emoji_spec.rb:80 UserEmoji#emoji_slots caps at level 30 undefined method `ceil' for Math:Module
spec/models/user_emoji_spec.rb:70 UserEmoji#emoji_slots returns 3 slots at level 4 undefined method `ceil' for Math:Module
spec/models/user_emoji_spec.rb:65 UserEmoji#emoji_slots returns 1 slot at level 3 undefined method `ceil' for Math:Module

@github-actions
Copy link
Copy Markdown

Slowest examples

Top 10 slowest examples (45.32 seconds, 85.71% of total time)
Example Description Time in seconds
spec/models/show_series_spec.rb:24 ShowSeries saving recurrences saves recurring shows 12.12051
spec/models/show_series_spec.rb:139 ShowSeries saving recurrences saves weekly show on correct weekday across DST spring-forward 7.27078
spec/models/show_series_spec.rb:90 ShowSeries saving recurrences handles crossing the DST boundry 4.82805
spec/services/process_recording_spec.rb:30 ProcessRecording assigns track to scheduled show 4.43518
spec/services/process_recording_spec.rb:17 ProcessRecording processes a recording 4.08139
spec/models/scheduled_show_spec.rb:337 ScheduledShow archive recordings starts processing the recording after assigning a recording, then assigns the track to the show 3.43335
spec/models/show_series_spec.rb:63 ShowSeries saving recurrences saves biweek with start date 3.2842
spec/models/show_series_spec.rb:73 ShowSeries saving recurrences updates all episodes with new time 2.6128
spec/models/show_series_spec.rb:123 ShowSeries saving recurrences saves monthly show on correct weekday across DST boundaries 1.66104
spec/models/show_series_spec.rb:152 ShowSeries saving recurrences maintains consistent local hour across DST transitions 1.59615

@mcfiredrill
Copy link
Copy Markdown
Member Author

pls fix error @copilot

#<NoMethodError: private method `can_create_custom_emoji?' called for #<User id: 26, email: "dj.nameko@datafruits.fm", created_at: "2015-04-17 09:38:46.169965000 +0000", updated_at: "2026-05-16 04:20:37.544369286 +0000", role: "dj", username: "djnameko", time_zone: "UTC", display_name: "", deleted_at: nil, enabled: true, referer: nil, bio: "yeah im freaky", image_file_name: "Booster_Artwork_-_Super_Mario_RPG.png", image_content_type: "image/png", image_file_size: 22492, image_updated_at: "2023-05-27 05:13:38.247023000 +0000", profile_publish: true, style: "slimey", pronouns: "shroom/shrem", homepage: "freaks.com", fruit_ticket_balance: 64, experience_points: 9116, level: 5>>

…solidation, spec updates

- Fix Math.sqrt(x).ceil (was Math.ceil(Math.sqrt(x))) in User::Rpg#emoji_slots
- Add custom_emojis and user_emojis tables to db/schema.rb
- Consolidate emoji slot logic in User: delegate emoji_slots_total to rpg.rb,
  fix emoji_slots_used to count custom_emojis (not user_emojis)
- Update user_emoji_spec.rb validations to test CustomEmoji with correct error messages

Agent-Logs-Url: https://github.com/datafruits/streampusher-api/sessions/633e5cd2-d35d-4d65-8cfb-c82130ce451d

Co-authored-by: mcfiredrill <66243+mcfiredrill@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 16, 2026

pls fix error @copilot

#<NoMethodError: private method `can_create_custom_emoji?' called for #<User id: 26, email: "dj.nameko@datafruits.fm", created_at: "2015-04-17 09:38:46.169965000 +0000", upd...

Fixed in commit 392d5c1. There were four root causes:

  1. Math.ceil doesn't exist in Rubyapp/models/user/rpg.rb was calling Math.ceil(Math.sqrt(lvl - 2)) instead of Math.sqrt(lvl - 2).ceil
  2. custom_emojis and user_emojis tables missing from db/schema.rb — causing PG::UndefinedTable errors
  3. emoji_slots_used was counting user_emojis instead of custom_emojis (the records that actually consume a slot)
  4. Spec validation tests were outdated — still testing UserEmoji with old error messages after the refactor moved validation logic to CustomEmoji

@mcfiredrill mcfiredrill requested a review from dudethatbe May 20, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants