creating statuses: am getting error SystemStackError (stack level too deep)

9 Views Asked by At
    am getting this error: SystemStackError (stack level too deep)

what is the problem:

#this is where a user creates status def create_status(user) duration = 1.day.to_i # Set status duration to 1 day # Check if the user is blocked #@user= User.find(user.id) puts "This is the real user making a request: #{@user.username}" blocked_user = BlockedUser.find_by(user_id: user.id) if blocked_user.present? && blocked_user.blocked? render json: { error: "Hi #{user.username} You have been blocked for violating Cash Chat User policies,Wait for 12 hours before you can post status" }, status: :unprocessable_entity else

   status_params = {
        body: params[:content],
        picture: @picture,
        video: @video,
        voice_note: @voice_note,
        background_color: @background_color,
         duration: duration
        }
        
   @status= @user.statuses.new(status_params)
   unless @status.save
   return render json: {
   success: false,
   result: "Status can't be blank"
   }, status: :unprocessable_entity
   end
   # Send notification to user's contacts
   if @status.present?
   registration_ids = user.contacts.map(&:registration_id)
   fcm = fcm_client
   response = fcm.send(registration_ids, fcm_options(user))
   puts response
   end
   
   render json: {
   success: true,
   info: "Status posted successfully",
   status_info: {
   id: @status.id,
   body: @status.body,
   picture: @status.picture,
   video: @status.video,
   voice_note: @status.voice_note,
   background_color: @status.background_color,
   expiry_time: duration,
   deleted_at: @status.deleted_at,
   created_at: @status.created_at,
   updated_at: @status.updated_at,
   
   fcm: fcm_options(user)
   }
   }, status: :ok
   
   record_activity("#{user.username} created a new status at #{DateTime.now}")
   create_visit
   end
   end
0

There are 0 best solutions below