Add checkin notifications for starting lectures

This commit is contained in:
2023-10-05 09:59:08 +01:00
parent 9e8cf93b1a
commit 04caed2783
7 changed files with 46 additions and 1 deletions
+12
View File
@@ -1,4 +1,16 @@
class LectureController < ApplicationController
# TODO: Pass the CSRF token to Pushcut
skip_before_action :verify_authenticity_token, only: [:checkin]
def checkin
lecture = Lecture.find(params[:id])
Toggl::start_time_entry(
description: lecture.title,
project_id: lecture.course.toggl_project,
)
end
def start
lecture = Lecture.find(params[:id])
+18
View File
@@ -0,0 +1,18 @@
class LectureCheckinJob < ApplicationJob
queue_as :default
def perform(*args)
lecture = Lecture.find_by(start_time: Time.now - 5.minutes..Time.now + 5.minutes)
return if lecture.empty?
puts(HTTParty.post(
"https://api.pushcut.io/2Kdtb5V7SoDXQOPxCJetk/notifications/Checkin",
body: {
input: lecture.id.to_s,
text: lecture.title,
title: "Checkin to #{lecture.course.title}"
}.to_json,
headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
))
end
end
+1 -1
View File
@@ -1,7 +1,7 @@
module Panopto
# @param [String] folder_id
def self.list_folder(folder_id)
HTTParty.get("https://lectures.joshuacoles.me/list", query: {
HTTParty.get("https://lectures.joshuacoles.me/api/list", query: {
folderId: folder_id
})
end