diff --git a/plugins/gitlab/server/gitlab.ts b/plugins/gitlab/server/gitlab.ts index deb21f9a07..dab94ae023 100644 --- a/plugins/gitlab/server/gitlab.ts +++ b/plugins/gitlab/server/gitlab.ts @@ -118,9 +118,12 @@ export class GitLab { // Get the first project the user has access to // In a real implementation, we would want to let the user select which project to connect - const res = await fetch("https://gitlab.com/api/v4/projects?membership=true&per_page=1", { - headers, - }); + const res = await fetch( + "https://gitlab.com/api/v4/projects?membership=true&per_page=1", + { + headers, + } + ); if (res.status !== 200) { throw new Error( @@ -168,7 +171,7 @@ export class GitLab { }; let apiUrl: string; - let resourceSchema: any; + let resourceSchema: z.ZodObject; let resourceType: UnfurlResourceType; if (resource.type === "issues") { @@ -214,7 +217,8 @@ export class GitLab { state: { name: data.state, color: data.state === "opened" ? "#1aaa55" : "#db3b21", // Green for open, red for closed - draft: resourceType === UnfurlResourceType.PR ? data.draft : undefined, + draft: + resourceType === UnfurlResourceType.PR ? data.draft : undefined, }, createdAt: data.created_at, } satisfies UnfurlIssueOrPR; @@ -256,11 +260,14 @@ export class GitLab { const type = parts[separatorIndex + 1]; const id = parts[separatorIndex + 2]; - if (!type || !id || !GitLab.supportedUnfurls.includes(type as UnfurlResourceType)) { + if ( + !type || + !id || + !GitLab.supportedUnfurls.includes(type as UnfurlResourceType) + ) { return; } return { projectPath, type, id }; } } - diff --git a/plugins/gitlab/server/tasks/UploadGitLabProjectAvatarTask.ts b/plugins/gitlab/server/tasks/UploadGitLabProjectAvatarTask.ts index 4d57c65b45..298affdbc9 100644 --- a/plugins/gitlab/server/tasks/UploadGitLabProjectAvatarTask.ts +++ b/plugins/gitlab/server/tasks/UploadGitLabProjectAvatarTask.ts @@ -1,4 +1,4 @@ -import { IntegrationService, IntegrationType } from "@shared/types"; +import { IntegrationType } from "@shared/types"; import BaseTask from "@server/queues/tasks/BaseTask"; import { Integration } from "@server/models"; import { FileOperation } from "@server/models"; @@ -14,13 +14,13 @@ export default class UploadGitLabProjectAvatarTask extends BaseTask { const integration = await Integration.findByPk(integrationId, { rejectOnEmpty: true, }); - + try { const res = await fetch(avatarUrl); const buffer = await res.buffer(); const name = avatarUrl.split("/").pop() || "avatar"; const contentType = res.headers.get("content-type") || "image/png"; - + const operation = await FileOperation.createFromBuffer({ buffer, contentType, @@ -29,7 +29,7 @@ export default class UploadGitLabProjectAvatarTask extends BaseTask { teamId: integration.teamId, source: "gitlab", }); - + await integration.update({ settings: { ...integration.settings, @@ -48,8 +48,9 @@ export default class UploadGitLabProjectAvatarTask extends BaseTask { // If the avatar upload fails, we don't need to fail the entire task // as it's not critical to the integration's functionality. // Just log the error and continue. - this.logger.error(`Failed to upload GitLab project avatar: ${err.message}`); + this.logger.error( + `Failed to upload GitLab project avatar: ${err.message}` + ); } } } - diff --git a/plugins/oidc/server/auth/OIDCStrategy.ts b/plugins/oidc/server/auth/OIDCStrategy.ts index c2a43f8fce..8a3dc04175 100644 --- a/plugins/oidc/server/auth/OIDCStrategy.ts +++ b/plugins/oidc/server/auth/OIDCStrategy.ts @@ -1,5 +1,6 @@ import { HttpsProxyAgent } from "https-proxy-agent"; import OAuth2Strategy, { Strategy } from "passport-oauth2"; +import { Request } from "express"; export class OIDCStrategy extends Strategy { constructor( @@ -14,12 +15,12 @@ export class OIDCStrategy extends Strategy { } } - authenticate(req: any, options: any) { + authenticate(req: Request, options: Record) { options.originalQuery = req.query; super.authenticate(req, options); } - authorizationParams(options: any) { + authorizationParams(options: Record) { return { ...options.originalQuery, ...super.authorizationParams?.(options), diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 4a4bb608ce..a3c439d27e 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -1182,6 +1182,10 @@ "Enabled by {{integrationCreatedBy}}": "Enabled by {{integrationCreatedBy}}", "Disconnecting will prevent previewing GitHub links from this organization in documents. Are you sure?": "Disconnecting will prevent previewing GitHub links from this organization in documents. Are you sure?", "The GitHub integration is currently disabled. Please set the associated environment variables and restart the server to enable the integration.": "The GitHub integration is currently disabled. Please set the associated environment variables and restart the server to enable the integration.", + "Whoops, you need to accept the permissions in GitLab to connect {{appName}} to your project. Try again?": "Whoops, you need to accept the permissions in GitLab to connect {{appName}} to your project. Try again?", + "Enable previews of GitLab issues and merge requests in documents by connecting a GitLab project to {appName}.": "Enable previews of GitLab issues and merge requests in documents by connecting a GitLab project to {appName}.", + "Disconnecting will prevent previewing GitLab links from this project in documents. Are you sure?": "Disconnecting will prevent previewing GitLab links from this project in documents. Are you sure?", + "The GitLab integration is currently disabled. Please set the associated environment variables and restart the server to enable the integration.": "The GitLab integration is currently disabled. Please set the associated environment variables and restart the server to enable the integration.", "Google Analytics": "Google Analytics", "Add a Google Analytics 4 measurement ID to send document views and analytics from the workspace to your own Google Analytics account.": "Add a Google Analytics 4 measurement ID to send document views and analytics from the workspace to your own Google Analytics account.", "Measurement ID": "Measurement ID",