diff --git a/lib/swimmy/command/attendance.rb b/lib/swimmy/command/attendance.rb index 098fd75..a14ce73 100644 --- a/lib/swimmy/command/attendance.rb +++ b/lib/swimmy/command/attendance.rb @@ -42,8 +42,12 @@ class Attendance < Swimmy::Command::Base client.say(channel: data.channel, text: "履歴を記録しました.") # attendance event (for doorplate) + attendance_labels = { + "hi" => "在室", + "bye" => "帰宅" + } doorplate_service = Swimmy::Service::Doorplate.new(mqtt_client) - doorplate_service.send_attendance_event(cmd, user_id, user_name) + doorplate_service.send_attendance_event(attendance_labels[cmd], user_name) end help do diff --git a/lib/swimmy/command/location.rb b/lib/swimmy/command/location.rb index 4e5f0d8..01bf628 100644 --- a/lib/swimmy/command/location.rb +++ b/lib/swimmy/command/location.rb @@ -41,7 +41,7 @@ class Location < Swimmy::Command::Base if match_locations.length == 1 begin doorplate_service = Swimmy::Service::Doorplate.new(mqtt_client) - doorplate_service.send_attendance_event(match_locations.keys.first, user_id, user_name) + doorplate_service.send_attendance_event(match_locations.values.first, user_name) rescue => e client.say(channel: data.channel, text: "ドアプレートの状態を更新できませんでした.") return diff --git a/lib/swimmy/service/doorplate.rb b/lib/swimmy/service/doorplate.rb index 7f4e0e2..90bb776 100644 --- a/lib/swimmy/service/doorplate.rb +++ b/lib/swimmy/service/doorplate.rb @@ -5,16 +5,13 @@ def initialize(mqtt_client) @mqtt = mqtt_client end - def send_attendance_event(attendance, user_id, user_name) + def send_attendance_event(attendance, user_name) require "json" - topic = "dt/swimmy/v1/ou/eng4/nomlab/swimmy/attend" + topic = "cmd/pinot/v1/ou/eng4/doormgr/state" payload = JSON.dump({ - attendance: attendance, - slack_user: { - id: user_id, - name: user_name, - }, + member: user_name.tr('-','_'), + position: attendance, }) @mqtt.publish(topic, payload)