mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-22 23:31:12 +02:00
Merge pull request #760 from AnishSarkar22/fix/connectors
fix: various issues with connectors & other issues
This commit is contained in:
commit
32ab938329
49 changed files with 1829 additions and 107 deletions
|
|
@ -5,6 +5,7 @@ import {
|
|||
type DeleteConnectorRequest,
|
||||
deleteConnectorRequest,
|
||||
deleteConnectorResponse,
|
||||
type DiscordChannel,
|
||||
type GetConnectorRequest,
|
||||
type GetConnectorsRequest,
|
||||
getConnectorRequest,
|
||||
|
|
@ -16,10 +17,13 @@ import {
|
|||
indexConnectorResponse,
|
||||
type ListGitHubRepositoriesRequest,
|
||||
type ListGoogleDriveFoldersRequest,
|
||||
listDiscordChannelsResponse,
|
||||
listGitHubRepositoriesRequest,
|
||||
listGitHubRepositoriesResponse,
|
||||
listGoogleDriveFoldersRequest,
|
||||
listGoogleDriveFoldersResponse,
|
||||
listSlackChannelsResponse,
|
||||
type SlackChannel,
|
||||
type UpdateConnectorRequest,
|
||||
updateConnectorRequest,
|
||||
updateConnectorResponse,
|
||||
|
|
@ -335,6 +339,36 @@ class ConnectorsApiService {
|
|||
}
|
||||
);
|
||||
};
|
||||
|
||||
// =============================================================================
|
||||
// Slack Connector Methods
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Get Slack channels with bot membership status
|
||||
*/
|
||||
getSlackChannels = async (connectorId: number) => {
|
||||
return baseApiService.get(
|
||||
`/api/v1/slack/connector/${connectorId}/channels`,
|
||||
listSlackChannelsResponse
|
||||
);
|
||||
};
|
||||
|
||||
// =============================================================================
|
||||
// Discord Connector Methods
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Get Discord text channels for a connector
|
||||
*/
|
||||
getDiscordChannels = async (connectorId: number) => {
|
||||
return baseApiService.get(
|
||||
`/api/v1/discord/connector/${connectorId}/channels`,
|
||||
listDiscordChannelsResponse
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export type { SlackChannel, DiscordChannel };
|
||||
|
||||
export const connectorsApiService = new ConnectorsApiService();
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ const pendingSyncs = new Map<string, Promise<SyncHandle>>();
|
|||
// Version for sync state - increment this to force fresh sync when Electric config changes
|
||||
// v2: user-specific database architecture
|
||||
// v3: consistent cutoff date for sync+queries, visibility refresh support
|
||||
const SYNC_VERSION = 3;
|
||||
// v4: heartbeat-based stale notification detection with updated_at tracking
|
||||
const SYNC_VERSION = 4;
|
||||
|
||||
// Database name prefix for identifying SurfSense databases
|
||||
const DB_PREFIX = "surfsense-";
|
||||
|
|
|
|||
24
surfsense_web/lib/format-date.ts
Normal file
24
surfsense_web/lib/format-date.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { differenceInDays, differenceInMinutes, format, isToday, isYesterday } from "date-fns";
|
||||
|
||||
/**
|
||||
* Format a date string as a human-readable relative time
|
||||
* - < 1 min: "Just now"
|
||||
* - < 60 min: "15m ago"
|
||||
* - Today: "Today, 2:30 PM"
|
||||
* - Yesterday: "Yesterday, 2:30 PM"
|
||||
* - < 7 days: "3d ago"
|
||||
* - Older: "Jan 15, 2026"
|
||||
*/
|
||||
export function formatRelativeDate(dateString: string): string {
|
||||
const date = new Date(dateString);
|
||||
const now = new Date();
|
||||
const minutesAgo = differenceInMinutes(now, date);
|
||||
const daysAgo = differenceInDays(now, date);
|
||||
|
||||
if (minutesAgo < 1) return "Just now";
|
||||
if (minutesAgo < 60) return `${minutesAgo}m ago`;
|
||||
if (isToday(date)) return `Today, ${format(date, "h:mm a")}`;
|
||||
if (isYesterday(date)) return `Yesterday, ${format(date, "h:mm a")}`;
|
||||
if (daysAgo < 7) return `${daysAgo}d ago`;
|
||||
return format(date, "MMM d, yyyy");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue