Skip to content

Commit

Permalink
use delimiter to distinguish view id and objectid
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerem Dokuz committed Sep 6, 2023
1 parent 3ec2339 commit 5ada4d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions sched_slack_bot/model/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from sched_slack_bot.utils.slack_typing_stubs import SlackState, SlackBody
from sched_slack_bot.views.schedule_dialog_block_ids import (
DISPLAY_NAME_BLOCK_ID,
SHEDULE_VIEW_ID_SCHEDULE_ID_DELIMITER,
USERS_INPUT_BLOCK_ID,
CHANNEL_INPUT_BLOCK_ID,
DatetimeSelectorType,
Expand Down Expand Up @@ -151,6 +152,9 @@ def from_modal_submission(cls, submission_body: SlackBody) -> Schedule:
if schedule_id.startswith(CREATE_NEW_SCHEDULE_VIEW_ID):
schedule_id = str(uuid.uuid4())

if SHEDULE_VIEW_ID_SCHEDULE_ID_DELIMITER in schedule_id:
schedule_id = schedule_id.split(SHEDULE_VIEW_ID_SCHEDULE_ID_DELIMITER)[0]

return Schedule(
id=schedule_id,
display_name=display_name,
Expand Down
3 changes: 2 additions & 1 deletion sched_slack_bot/views/schedule_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from sched_slack_bot.views.schedule_dialog_block_ids import (
DISPLAY_NAME_BLOCK_ID,
CHANNEL_INPUT_BLOCK_ID,
SHEDULE_VIEW_ID_SCHEDULE_ID_DELIMITER,
USERS_INPUT_BLOCK_ID,
FIRST_ROTATION_LABEL,
SECOND_ROTATION_LABEL,
Expand Down Expand Up @@ -87,7 +88,7 @@ def get_edit_schedule_block(
modal_type = CREATE_MODAL_TYPE if schedule is None else EDIT_MODAL_TYPE
# make sure external id is unique globally: https://github.com/slackapi/node-slack-sdk/issues/1012#issuecomment-684818059
external_id = schedule.id if schedule is not None else CREATE_NEW_SCHEDULE_VIEW_ID
external_id = f"{external_id}-{str(uuid.uuid4())}"
external_id = f"{external_id}{SHEDULE_VIEW_ID_SCHEDULE_ID_DELIMITER}{str(uuid.uuid4())}"
return View(
type="modal",
external_id=external_id,
Expand Down
2 changes: 2 additions & 0 deletions sched_slack_bot/views/schedule_dialog_block_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

CREATE_NEW_SCHEDULE_VIEW_ID = "NEW_DIALOG"

SHEDULE_VIEW_ID_SCHEDULE_ID_DELIMITER = "::"


class DatetimeSelectorType(Enum):
DATE = "DATE"
Expand Down

0 comments on commit 5ada4d2

Please sign in to comment.