Permalink
Browse files

missing closes

  • Loading branch information...
sorah committed Oct 22, 2017
1 parent bf0e166 commit 159219416fa478d40e9ba9e4a7d3c7cac352c663
Showing with 3 additions and 0 deletions.
  1. +3 −0 isubata/webapp/ruby/app.rb
@@ -131,6 +131,7 @@ def user
name = params[:name]
statement = db.prepare('SELECT * FROM user WHERE name = ?')
row = statement.execute(name).first
statement.close
if row.nil? || row['password'] != Digest::SHA1.hexdigest(row['salt'] + params[:password])
return 403
end
@@ -164,6 +165,7 @@ def user
last_message_id = params[:last_message_id].to_i
statement = db.prepare('SELECT * FROM message WHERE id > ? AND channel_id = ? ORDER BY id DESC LIMIT 100')
rows = statement.execute(last_message_id, channel_id).to_a
statement.close
users = get_users(rows.map { |r| r['user_id'] }.uniq)
response = []
rows.each do |row|
@@ -185,6 +187,7 @@ def user
'ON DUPLICATE KEY UPDATE message_id = ?, updated_at = NOW()',
].join)
statement.execute(user_id, channel_id, max_message_id, max_message_id)
statement.close
content_type :json
response.to_json

0 comments on commit 1592194

Please sign in to comment.