Skip to content

Commit

Permalink
Additional zoom account fixes (#401)
Browse files Browse the repository at this point in the history
* Remove Zoom as a meeting link provider if they disconnect their zoom account

* Hide the video link text field if they want zoom meeting links generated
  • Loading branch information
MelissaAutumn authored and jdbass committed May 17, 2024
1 parent 4ae6783 commit 65bda8c
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
8 changes: 7 additions & 1 deletion backend/src/appointment/routes/zoom.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from ..controller.apis.zoom_client import ZoomClient
from ..controller.auth import sign_url
from ..database import repo, schemas
from ..database import repo, schemas, models
from ..database.models import Subscriber, ExternalConnectionType
from ..dependencies.auth import get_subscriber
from ..dependencies.database import get_db
Expand Down Expand Up @@ -85,6 +85,12 @@ def disconnect_account(

if zoom_connection:
repo.external_connection.delete_by_type(db, subscriber.id, zoom_connection.type, zoom_connection.type_id)
schedules = repo.schedule.get_by_subscriber(db, subscriber.id)
for schedule in schedules:
if schedule.meeting_link_provider == models.MeetingLinkProviderType.zoom:
schedule.meeting_link_provider = models.MeetingLinkProviderType.none
db.add(schedule)
db.commit()
else:
return False

Expand Down
3 changes: 2 additions & 1 deletion backend/test/factory/schedule_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def _make_schedule(calendar_id=FAKER_RANDOM_VALUE,
farthest_booking=FAKER_RANDOM_VALUE,
weekdays=[1,2,3,4,5],
slot_duration=FAKER_RANDOM_VALUE,
meeting_link_provider=models.MeetingLinkProviderType.none,
):
with with_db() as db:
return repo.schedule.create(db, schemas.ScheduleBase(
Expand All @@ -39,7 +40,7 @@ def _make_schedule(calendar_id=FAKER_RANDOM_VALUE,
farthest_booking=farthest_booking if factory_has_value(farthest_booking) else fake.pyint(15, 60),
weekdays=weekdays,
slot_duration=slot_duration if factory_has_value(slot_duration) else fake.pyint(15, 60),
meeting_link_provider=models.MeetingLinkProviderType.none,
meeting_link_provider=meeting_link_provider,
calendar_id=calendar_id if factory_has_value(calendar_id) else make_caldav_calendar(connected=True).id
))

Expand Down
62 changes: 62 additions & 0 deletions backend/test/integration/test_zoom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

from appointment.database import models
from defines import auth_headers, TEST_USER_ID


class TestZoom:
def test_zoom_disconnect_without_connection(self, with_client):
response = with_client.post(
"/zoom/disconnect",
headers=auth_headers)
assert response.status_code == 200
assert response.json() is False

def test_zoom_disconnect_with_connection(self, with_client, make_external_connections):
make_external_connections(TEST_USER_ID, type=models.ExternalConnectionType.zoom)

response = with_client.post(
"/zoom/disconnect",
headers=auth_headers)
assert response.status_code == 200
assert response.json() is True

def test_zoom_disconnect_updates_schedule(self, with_db, with_client, make_schedule, make_external_connections):
make_external_connections(TEST_USER_ID, type=models.ExternalConnectionType.zoom)
schedule = make_schedule(meeting_link_provider=models.MeetingLinkProviderType.zoom)

assert schedule.meeting_link_provider == models.MeetingLinkProviderType.zoom

response = with_client.post(
"/zoom/disconnect",
headers=auth_headers)
assert response.status_code == 200
assert response.json() is True

# Refresh the schedule now that the zoom account is gone,
# and our meeting link provider should be none
with with_db() as db:
db.add(schedule)
db.refresh(schedule)

assert schedule.meeting_link_provider == models.MeetingLinkProviderType.none

def test_zoom_disconnect_does_not_update_schedule_for_other_types(self, with_db, with_client, make_schedule,
make_external_connections):
make_external_connections(TEST_USER_ID, type=models.ExternalConnectionType.zoom)
schedule = make_schedule(meeting_link_provider=models.MeetingLinkProviderType.google_meet)

assert schedule.meeting_link_provider == models.MeetingLinkProviderType.google_meet

response = with_client.post(
"/zoom/disconnect",
headers=auth_headers)
assert response.status_code == 200
assert response.json() is True

# Refresh the schedule now that the zoom account is gone,
# and our meeting link provider should still be google meet
with with_db() as db:
db.add(schedule)
db.refresh(schedule)

assert schedule.meeting_link_provider == models.MeetingLinkProviderType.google_meet
1 change: 1 addition & 0 deletions frontend/src/components/ScheduleCreation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
<input
type="text"
v-model="scheduleInput.location_url"
v-if="scheduleInput.meeting_link_provider === meetingLinkProviderType.none"
:placeholder="t('placeholder.zoomCom')"
:disabled="!scheduleInput.active || scheduleInput.meeting_link_provider !== meetingLinkProviderType.none"
class="place-holder w-full rounded-md disabled:cursor-not-allowed"
Expand Down

0 comments on commit 65bda8c

Please sign in to comment.