From 669b7798db01297dd33ca0dd958cf5f9f2b12ca6 Mon Sep 17 00:00:00 2001
From: Lola <68611399+lunchpaillola@users.noreply.github.com>
Date: Tue, 16 Nov 2021 09:12:10 -0500
Subject: [PATCH] Enable Recording in Daily Video Calls (#1141)

* :arrow_up: Bump tailwindcss from 2.2.14 to 2.2.15

Bumps [tailwindcss](https://github.com/tailwindlabs/tailwindcss) from 2.2.14 to 2.2.15.
- [Release notes](https://github.com/tailwindlabs/tailwindcss/releases)
- [Changelog](https://github.com/tailwindlabs/tailwindcss/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tailwindlabs/tailwindcss/compare/v2.2.14...v2.2.15)

---
updated-dependencies:
- dependency-name: tailwindcss
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* updating cal will provide a zoom meeting url

* updating cal will provide a zoom meeting url

* modifying how daily emails send

* modifying how daily emails send

* daily table

* migration updates

* rebasing updates

* updating Daily references to a new table

* merge updates, adding Daily references to book/events.ts

* updated video email templates to remove Daily specific references

* updating the events.ts and refactoring in the event manager

* removing the package-lock

* updating some of the internal Daily notes

* removing handle errors raw from the Daily video client

* prettier formatting fixes

* Added the Daily location to calendar events and updated Cal video references to Daily.co video

* updating references to create in event manager to check for Daily video

* adding a daily interface in the event manager

* adding daily to the location labels

* resolving yarn merge conflicts

* removing prettier auto and refactoring integrations: daily in the event manager

* removing changes to estlintrc.json

* updating message when daily video call meeting has not started

* updated modal time buffer

* changed video calls to Cal colors

* removing change to undoing change to lodash/merge on the event manager

* removing change on the event-types to match the main repo

* updating the border color in daily video calls

* updating cal will provide a zoom meeting url

* updating cal will provide a zoom meeting url

* modifying how daily emails send

* modifying how daily emails send

* daily table

* migration updates

* rebasing updates

* updating Daily references to a new table

* merge updates, adding Daily references to book/events.ts

* updated video email templates to remove Daily specific references

* updating the events.ts and refactoring in the event manager

* removing the package-lock

* updating some of the internal Daily notes

* removing handle errors raw from the Daily video client

* prettier formatting fixes

* Added the Daily location to calendar events and updated Cal video references to Daily.co video

* updating references to create in event manager to check for Daily video

* adding a daily interface in the event manager

* adding daily to the location labels

* resolving yarn merge conflicts

* removing prettier auto and refactoring integrations: daily in the event manager

* removing changes to estlintrc.json

* updated modal time buffer

* updates to enable recording

* removed the console log line for debugging int he DailyVideoAdapter

* removed the env copy created here

* updating readme and chaging Daily Scale Plan variable to true

* merge changes

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Lola-Ojabowale <lola.ojabowale@gmail.com>
---
 .env.example                                   |  1 +
 README.md                                      |  1 +
 lib/integrations/Daily/DailyVideoApiAdapter.ts | 17 +++++++++++++++++
 3 files changed, 19 insertions(+)

diff --git a/.env.example b/.env.example
index 418388c3..42c804a8 100644
--- a/.env.example
+++ b/.env.example
@@ -34,6 +34,7 @@ ZOOM_CLIENT_SECRET=
 
 #Used for the Daily integration
 DAILY_API_KEY=
+DAILY_SCALE_PLAN=''
 
 # E-mail settings
 
diff --git a/README.md b/README.md
index 49b3aeac..5cc0c7f6 100644
--- a/README.md
+++ b/README.md
@@ -293,6 +293,7 @@ Contributions are what make the open source community such an amazing place to b
  2. From within your dashboard, go to the [developers](https://dashboard.daily.co/developers) tab.
  3. Copy your API key.
  4. Now paste the API key to your .env file into the `DAILY_API_KEY` field in your .env file.
+ 5. If you have a [Daily Scale Plan](https://www.daily.co/pricing)  can also enable the ability to record Daily video meetings. To do so, set the `DAILY_SCALE_PLAN` environment variable to `'true'` 
 
 <!-- LICENSE -->
 
diff --git a/lib/integrations/Daily/DailyVideoApiAdapter.ts b/lib/integrations/Daily/DailyVideoApiAdapter.ts
index dd4c11af..84515bd8 100644
--- a/lib/integrations/Daily/DailyVideoApiAdapter.ts
+++ b/lib/integrations/Daily/DailyVideoApiAdapter.ts
@@ -97,6 +97,23 @@ const DailyVideoApiAdapter = (credential: Credential): VideoApiAdapter => {
     // added a 1 hour buffer for room expiration and room entry
     const exp = Math.round(new Date(event.endTime).getTime() / 1000) + 60 * 60;
     const nbf = Math.round(new Date(event.startTime).getTime() / 1000) - 60 * 60;
+    const scalePlan = process.env.DAILY_SCALE_PLAN;
+
+    if (scalePlan === "true") {
+      return {
+        privacy: "private",
+        properties: {
+          enable_new_call_ui: true,
+          enable_prejoin_ui: true,
+          enable_knocking: true,
+          enable_screenshare: true,
+          enable_chat: true,
+          exp: exp,
+          nbf: nbf,
+          enable_recording: "local",
+        },
+      };
+    }
     return {
       privacy: "private",
       properties: {