simukappu / activity_notification

Integrated user activity notifications for Ruby on Rails
https://rubygems.org/gems/activity_notification
MIT License
507 stars 79 forks source link

Get notifications endpoint return 204 status !! #135

Closed seifoueddine closed 4 years ago

seifoueddine commented 4 years ago

I have a basic setup with rails API + devise_token_auth and angular9 app for the Front. I add activity_notification gem, and I add the basic configuration

appointment.rb

class Appointment < ApplicationRecord
  validates_uniqueness_of :start_time
  belongs_to :slug
  belongs_to :user
  belongs_to :property
  belongs_to :contact
  acts_as_notifiable :users,
                     targets: lambda { |appointment, key|
                       User.where(slug_id: appointment.user.slug_id )
                     }, notifiable_path: :appointment_notifiable_path

  def appointment_notifiable_path
    'just path'
  end
end

appointment_controller.rb

def create
    slug_id = get_slug_id
    params[:slug_id] = slug_id
    @appointment = Appointment.new(appointment_params)

    if @appointment.save
      @appointment.notify :users, key: '2'
      render json: @appointment, status: :created
    else
      render json: @appointment.errors, status: :unprocessable_entity
    end
  end 

routes.rb

scope :api do
    scope :v1 do
      notify_to :users, api_mode: true
    end
  end

the notification saved on notifications table, but when I want to get notifications for some user using this :

localhost:3000/api/v1/users/user_id/notifications

I see this in log

Completed 204 No Content in 53ms (ActiveRecord: 12.1ms | Allocations: 10420)

any explication, please!

simukappu commented 4 years ago

Thank you for your feedback. What is the HTTP response of http://localhost:3000/api/v1/users/user_id/notifications? Is this 204 No Content? Get request to notifications API should not return 204, so I would like to make it clear. https://app.swaggerhub.com/apis-docs/simukappu/activity-notification/2.1.0#/notifications/getNotifications

simukappu commented 4 years ago

Closing this issue for now. Please reopen if required.