aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorre4k <re4k@re4k.info>2013-04-26 19:19:19 +0900
committerre4k <re4k@re4k.info>2013-04-26 19:19:19 +0900
commit26b8a1a12c535883bd5e6d9d5765cada6aad5d70 (patch)
treed282ba8a261782c648a1388379e517abe01195fe /app
parentdf7193a73e0e4b682e292e1eaab9f9ac0e1ab982 (diff)
downloadaclog-26b8a1a12c535883bd5e6d9d5765cada6aad5d70.tar.gz
extract to Account#update_connection (send account information to receiver daemon)
Diffstat (limited to 'app')
-rw-r--r--app/controllers/sessions_controller.rb14
-rw-r--r--app/models/account.rb13
2 files changed, 15 insertions, 12 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 74577ec..a924ffc 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -8,21 +8,11 @@ class SessionsController < ApplicationController
oauth_token: auth["credentials"]["token"],
oauth_token_secret: auth["credentials"]["secret"],
consumer_version: Settings.consumer_version)
+ account.update_connection
+
session[:account] = account
session[:user_id] = account.user_id
- begin
- UNIXSocket.open(Settings.register_server_path) do |socket|
- socket.write({type: "register",
- id: account.id,
- user_id: account.user_id}.to_msgpack)
- end
- rescue Exception
- # receiver not started?
- warn $!
- warn $@
- end
-
redirect_to root_path
end
diff --git a/app/models/account.rb b/app/models/account.rb
index aed183d..deafdbe 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -10,6 +10,19 @@ class Account < ActiveRecord::Base
account
end
+ def update_connection
+ begin
+ UNIXSocket.open(Settings.register_server_path) do |socket|
+ socket.write({type: "register",
+ id: self.id,
+ user_id: self.user_id}.to_msgpack)
+ end
+ rescue Exception => ex
+ # receiver not started?
+ logger.error("Could't send account info to receiver daemon: #{ex}")
+ end
+ end
+
def client
Twitter::Client.new(
consumer_key: Settings.consumer[consumer_version.to_i].key,