Skip to content

refactor: extract duplicated Slack/PacificTime code into SharedKernel utilities#3

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782424418-shared-utilities
Open

refactor: extract duplicated Slack/PacificTime code into SharedKernel utilities#3
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782424418-shared-utilities

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Eliminates ~490 net lines of duplicated infrastructure between the YouTubeComments and YouTubeUploads modules by extracting three shared utilities into Hookline.SharedKernel:

1. SharedKernel.Common.PacificTime — single source of truth for PT timezone logic (quota resets at PT midnight). Modules keep thin internal facades delegating to the shared impl:

// Module facade (preserves internal API + namespace)
internal static class PacificTime
{
    public static string TodayKey() => SharedKernel.Common.PacificTime.TodayKey();
    public static TimeSpan UntilMidnight() => SharedKernel.Common.PacificTime.UntilMidnight();
}

2. SharedKernel.Slack.SlackSignatureVerifier — the identical 36-line HMAC-SHA256 + constant-time compare implementation was duplicated verbatim in both modules. Now a single public sealed class in SharedKernel; modules register it directly via DI.

3. SharedKernel.Slack.SlackSocketModeServiceBase — abstract BackgroundService encapsulating ~130 lines of WebSocket transport (connection open, receive loop, ACK, reconnect, error isolation). Modules subclass and implement only DispatchEnvelopeAsync:

// Comments: routes only "interactive" envelopes
protected override Task DispatchEnvelopeAsync(IServiceProvider sp, string? type, JsonElement payload, CancellationToken ct)
{
    if (type != "interactive") return Task.CompletedTask;
    return YouTubeCommentsProviderEndpoints.DispatchBlockActionsAsync(payload, ...);
}

// Uploads: routes "events_api" + "interactive"
protected override Task DispatchEnvelopeAsync(...) => type switch { "events_api" => ..., "interactive" => ... };

Net diff: +179 / −668 lines. All existing tests and architecture constraints pass unchanged.

Link to Devin session: https://app.devin.ai/sessions/672d4d38efcc4a0cac0d2a6c297166ca
Requested by: @skyp1nus

- PacificTime: centralized Pacific TZ logic in SharedKernel; modules
  delegate via thin facades preserving internal APIs
- SlackSignatureVerifier: single sealed implementation in SharedKernel;
  deleted identical 36-line copies from both modules
- SlackSocketModeServiceBase: abstract base class encapsulating ~130
  lines of WebSocket transport (connection, reconnect, ACK, error
  isolation); modules subclass and implement DispatchEnvelopeAsync
  for their specific envelope routing

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@skyp1nus skyp1nus self-assigned this Jun 25, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant