Class: Booth::Userland::PersonalContests::Show

Inherits:
Object
  • Object
show all
Includes:
Concerns::Action
Defined in:
lib/booth/userland/personal_contests/show.rb

Instance Method Summary collapse

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/booth/userland/personal_contests/show.rb', line 7

def call
  request.must_be_get!
  request.must_be_html!
  request.must_be_logged_in!

  debug { 'You want to receive your personal contest...' }

  if contest.failure?
    debug { "This credential doesn't have any contest right now." }
    return Tron.success :not_contested, step: :not_contested
  end

  if contest.recently_responded
    debug { 'The current contest has already been responded to' }
    return Tron.success :contest_responded, step: :contest_solved
  end

  step = case contest.reason
         when :login   then :remote_login
         when :support then :support_authentication
         else               raise "Unknown contest reason: #{contest.reason}"
         end

  debug { 'You have a contest to respond to' }
  Tron.success :you_are_contested,
               ip: contest.ip,
               agent: contest.agent.presence,
               location: contest.location.presence,
               browser_name: contest.browser_name,
               platform_name: contest.platform_name,
               browser_image_path: contest.browser_image_path,
               platform_image_path: contest.platform_image_path,
               step:
end