mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-04 12:51:37 -05:00
fix: slack integration crashing (#4254)
This commit is contained in:
committed by
GitHub
parent
3be78f0312
commit
1bcdf06b43
@@ -70,7 +70,7 @@ const Page = async ({ params }) => {
|
||||
return (
|
||||
<PageContentWrapper>
|
||||
<GoBackButton url={`${WEBAPP_URL}/environments/${params.environmentId}/integrations`} />
|
||||
<PageHeader pageTitle={"environments.integrations.slack.slack_integration"} />
|
||||
<PageHeader pageTitle={t("environments.integrations.slack.slack_integration")} />
|
||||
<div className="h-[75vh] w-full">
|
||||
<SlackWrapper
|
||||
isEnabled={isEnabled}
|
||||
|
||||
@@ -22,19 +22,33 @@ export const GET = async (req: NextRequest) => {
|
||||
if (!SLACK_CLIENT_ID) return responses.internalServerErrorResponse("Slack client id is missing");
|
||||
if (!SLACK_CLIENT_SECRET) return responses.internalServerErrorResponse("Slack client secret is missing");
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("code", code ?? "");
|
||||
formData.append("client_id", SLACK_CLIENT_ID ?? "");
|
||||
formData.append("client_secret", SLACK_CLIENT_SECRET ?? "");
|
||||
|
||||
const formData = {
|
||||
code,
|
||||
client_id: SLACK_CLIENT_ID,
|
||||
client_secret: SLACK_CLIENT_SECRET,
|
||||
};
|
||||
const formBody: string[] = [];
|
||||
for (const property in formData) {
|
||||
const encodedKey = encodeURIComponent(property);
|
||||
const encodedValue = encodeURIComponent(formData[property]);
|
||||
formBody.push(encodedKey + "=" + encodedValue);
|
||||
}
|
||||
const bodyString = formBody.join("&");
|
||||
if (code) {
|
||||
const response = await fetch("https://slack.com/api/oauth.v2.access", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
body: bodyString,
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (!data.ok) {
|
||||
return responses.badRequestResponse(data.error);
|
||||
}
|
||||
|
||||
const slackCredentials: TIntegrationSlackCredential = {
|
||||
app_id: data.app_id,
|
||||
authed_user: data.authed_user,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ProductConfigNavigation } from "@/app/(app)/environments/[environmentId]/product/components/ProductConfigNavigation";
|
||||
import { AccessView } from "@/modules/ee/teams/product-teams/components/access-view";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { getMultiLanguagePermission, getRoleManagementPermission } from "@formbricks/ee/lib/service";
|
||||
import { authOptions } from "@formbricks/lib/authOptions";
|
||||
import { getMembershipByUserIdOrganizationId } from "@formbricks/lib/membership/service";
|
||||
@@ -12,6 +13,7 @@ import { PageHeader } from "@formbricks/ui/components/PageHeader";
|
||||
import { getTeamsByOrganizationId, getTeamsByProductId } from "./lib/teams";
|
||||
|
||||
export const ProductTeams = async ({ params }: { params: { environmentId: string } }) => {
|
||||
const t = await getTranslations();
|
||||
const [product, session, organization] = await Promise.all([
|
||||
getProductByEnvironmentId(params.environmentId),
|
||||
getServerSession(authOptions),
|
||||
@@ -19,13 +21,13 @@ export const ProductTeams = async ({ params }: { params: { environmentId: string
|
||||
]);
|
||||
|
||||
if (!product) {
|
||||
throw new Error("Product not found");
|
||||
throw new Error(t("common.product_not_found"));
|
||||
}
|
||||
if (!session) {
|
||||
throw new Error("Unauthorized");
|
||||
throw new Error(t("common.session_not_found"));
|
||||
}
|
||||
if (!organization) {
|
||||
throw new Error("Organization not found");
|
||||
throw new Error(t("common.organization_not_found"));
|
||||
}
|
||||
|
||||
const currentUserMembership = await getMembershipByUserIdOrganizationId(session?.user.id, organization.id);
|
||||
@@ -37,20 +39,20 @@ export const ProductTeams = async ({ params }: { params: { environmentId: string
|
||||
const teams = await getTeamsByProductId(product.id);
|
||||
|
||||
if (!teams) {
|
||||
throw new Error("Teams not found");
|
||||
throw new Error(t("common.teams_not_found"));
|
||||
}
|
||||
|
||||
const organizationTeams = await getTeamsByOrganizationId(organization.id);
|
||||
|
||||
if (!organizationTeams) {
|
||||
throw new Error("Organization Teams not found");
|
||||
throw new Error(t("common.organization_teams_not_found"));
|
||||
}
|
||||
|
||||
const isOwnerOrManager = isOwner || isManager;
|
||||
|
||||
return (
|
||||
<PageContentWrapper>
|
||||
<PageHeader pageTitle="Configuration">
|
||||
<PageHeader pageTitle={t("common.configuration")}>
|
||||
<ProductConfigNavigation
|
||||
environmentId={params.environmentId}
|
||||
activeId="teams"
|
||||
|
||||
@@ -2,6 +2,7 @@ import { OrganizationSettingsNavbar } from "@/app/(app)/environments/[environmen
|
||||
import { TeamsView } from "@/modules/ee/teams/team-list/components/teams-view";
|
||||
import { getTeams } from "@/modules/ee/teams/team-list/lib/teams";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { notFound } from "next/navigation";
|
||||
import { getRoleManagementPermission } from "@formbricks/ee/lib/service";
|
||||
import { authOptions } from "@formbricks/lib/authOptions";
|
||||
@@ -13,14 +14,15 @@ import { PageContentWrapper } from "@formbricks/ui/components/PageContentWrapper
|
||||
import { PageHeader } from "@formbricks/ui/components/PageHeader";
|
||||
|
||||
export const TeamsPage = async ({ params }) => {
|
||||
const t = await getTranslations();
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session) {
|
||||
throw new Error("Unauthenticated");
|
||||
throw new Error(t("common.session_not_found"));
|
||||
}
|
||||
const organization = await getOrganizationByEnvironmentId(params.environmentId);
|
||||
|
||||
if (!organization) {
|
||||
throw new Error("Organization not found");
|
||||
throw new Error(t("common.organization_not_found"));
|
||||
}
|
||||
|
||||
const canDoRoleManagement = await getRoleManagementPermission(organization);
|
||||
@@ -34,12 +36,12 @@ export const TeamsPage = async ({ params }) => {
|
||||
const teams = await getTeams(session.user.id, organization.id);
|
||||
|
||||
if (!teams) {
|
||||
throw new Error("Teams not found");
|
||||
throw new Error(t("common.teams_not_found"));
|
||||
}
|
||||
|
||||
return (
|
||||
<PageContentWrapper>
|
||||
<PageHeader pageTitle="Organization Settings">
|
||||
<PageHeader pageTitle={t("environments.settings.general.organization_settings")}>
|
||||
<OrganizationSettingsNavbar
|
||||
environmentId={params.environmentId}
|
||||
isFormbricksCloud={IS_FORMBRICKS_CLOUD}
|
||||
|
||||
@@ -367,7 +367,9 @@
|
||||
"targeting": "Targeting",
|
||||
"team": "Team",
|
||||
"team_access": "Teamzugriff",
|
||||
"team_not_found": "Team nicht gefunden",
|
||||
"teams": "Teams",
|
||||
"teams_not_found": "Teams nicht gefunden",
|
||||
"text": "Text",
|
||||
"time": "Zeit",
|
||||
"time_to_finish": "Zeit zum Fertigstellen",
|
||||
|
||||
@@ -367,7 +367,9 @@
|
||||
"targeting": "Targeting",
|
||||
"team": "Team",
|
||||
"team_access": "Team Access",
|
||||
"team_not_found": "Team not found",
|
||||
"teams": "Teams",
|
||||
"teams_not_found": "Teams not found",
|
||||
"text": "Text",
|
||||
"time": "Time",
|
||||
"time_to_finish": "Time to finish",
|
||||
|
||||
@@ -367,7 +367,9 @@
|
||||
"targeting": "mirando",
|
||||
"team": "Time",
|
||||
"team_access": "Acesso da equipe",
|
||||
"team_not_found": "Equipe não encontrada",
|
||||
"teams": "Times",
|
||||
"teams_not_found": "Equipes não encontradas",
|
||||
"text": "Texto",
|
||||
"time": "tempo",
|
||||
"time_to_finish": "Hora de terminar",
|
||||
|
||||
Reference in New Issue
Block a user