mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
Merge branch 'master' of https://github.com/OneUptime/oneuptime
This commit is contained in:
@@ -32,7 +32,6 @@ import ObjectID from "../../../../Types/ObjectID";
|
||||
import WorkspaceProjectAuthTokenService from "../../../Services/WorkspaceProjectAuthTokenService";
|
||||
import WorkspaceProjectAuthToken, {
|
||||
MicrosoftTeamsMiscData,
|
||||
MicrosoftTeamsTeam,
|
||||
} from "../../../../Models/DatabaseModels/WorkspaceProjectAuthToken";
|
||||
import Incident from "../../../../Models/DatabaseModels/Incident";
|
||||
import IncidentState from "../../../../Models/DatabaseModels/IncidentState";
|
||||
@@ -2940,12 +2939,10 @@ All monitoring checks are passing normally.`;
|
||||
// Fetch joined teams using app-scoped token
|
||||
if (data.userId) {
|
||||
logger.debug("Using app-scoped token to fetch joined teams for user");
|
||||
const userTeams: Record<string, { id: string; name: string }> =
|
||||
await this.getUserJoinedTeams({
|
||||
userId: data.userId,
|
||||
projectId: data.projectId,
|
||||
});
|
||||
allTeams = Object.values(userTeams) as any;
|
||||
allTeams = await this.getUserJoinedTeams({
|
||||
userId: data.userId,
|
||||
projectId: data.projectId,
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn(
|
||||
@@ -3069,7 +3066,7 @@ All monitoring checks are passing normally.`;
|
||||
public static async getUserJoinedTeams(data: {
|
||||
userId: ObjectID;
|
||||
projectId: ObjectID;
|
||||
}): Promise<Record<string, { id: string; name: string }>> {
|
||||
}): Promise<Array<JSONObject>> {
|
||||
logger.debug("=== getUserJoinedTeams called ===");
|
||||
logger.debug(`User ID: ${data.userId.toString()}`);
|
||||
logger.debug(`Project ID: ${data.projectId.toString()}`);
|
||||
@@ -3123,29 +3120,9 @@ All monitoring checks are passing normally.`;
|
||||
const teams: Array<JSONObject> =
|
||||
(teamsData["value"] as Array<JSONObject>) || [];
|
||||
|
||||
if (teams.length === 0) {
|
||||
logger.debug("No joined teams found for user");
|
||||
return {};
|
||||
}
|
||||
logger.debug(`Fetched ${teams.length} joined teams`);
|
||||
|
||||
// Process teams
|
||||
const availableTeams: Record<string, MicrosoftTeamsTeam> = teams.reduce(
|
||||
(acc: Record<string, MicrosoftTeamsTeam>, t: JSONObject) => {
|
||||
const team: MicrosoftTeamsTeam = {
|
||||
id: t["id"] as string,
|
||||
name: (t["displayName"] as string) || "Unnamed Team",
|
||||
};
|
||||
acc[team.name] = team;
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, MicrosoftTeamsTeam>,
|
||||
);
|
||||
|
||||
logger.debug(
|
||||
`Fetched ${Object.keys(availableTeams).length} joined teams`,
|
||||
);
|
||||
|
||||
return availableTeams;
|
||||
return teams;
|
||||
} catch (error) {
|
||||
logger.error("Error getting user joined teams:");
|
||||
logger.error(error);
|
||||
|
||||
Reference in New Issue
Block a user