mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
Implemented Email Domains which allows Platform/Enterprise customers to send emails to recipients using their custom emails.
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
|
import { buildTeamWhereQuery, extractDerivedTeamSettings } from '../../utils/teams';
|
|
|
|
export type GetTeamSettingsOptions = {
|
|
userId?: number;
|
|
teamId: number;
|
|
};
|
|
|
|
/**
|
|
* You must provide userId if you want to validate whether the user can access the team settings.
|
|
*/
|
|
export const getTeamSettings = async ({ userId, teamId }: GetTeamSettingsOptions) => {
|
|
const team = await prisma.team.findFirst({
|
|
where: userId !== undefined ? buildTeamWhereQuery({ teamId, userId }) : { id: teamId },
|
|
include: {
|
|
organisation: {
|
|
include: {
|
|
organisationGlobalSettings: true,
|
|
},
|
|
},
|
|
teamGlobalSettings: true,
|
|
},
|
|
});
|
|
|
|
if (!team) {
|
|
throw new AppError(AppErrorCode.NOT_FOUND, {
|
|
message: 'Team not found',
|
|
});
|
|
}
|
|
|
|
const organisationSettings = team.organisation.organisationGlobalSettings;
|
|
const teamSettings = team.teamGlobalSettings;
|
|
|
|
// Override branding settings if inherit is enabled.
|
|
if (teamSettings.brandingEnabled === null) {
|
|
teamSettings.brandingEnabled = organisationSettings.brandingEnabled;
|
|
teamSettings.brandingLogo = organisationSettings.brandingLogo;
|
|
teamSettings.brandingUrl = organisationSettings.brandingUrl;
|
|
teamSettings.brandingCompanyDetails = organisationSettings.brandingCompanyDetails;
|
|
}
|
|
|
|
return extractDerivedTeamSettings(organisationSettings, teamSettings);
|
|
};
|