Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to add channel command using TeamName Closes#2419 #2472

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/m365/teams/commands/channel/channel-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,23 @@ class TeamsChannelAddCommand extends GraphCommand {
.get<{ value: Team[] }>(teamRequestOptions)
.then(response => {
const teamItem: Team | undefined = response.value[0];

if (!teamItem) {
return Promise.reject(`The specified team does not exist in the Microsoft Teams`);
}

let teamId = teamItem.id;
if (response.value.length > 1) {
return Promise.reject(`Multiple Microsoft Teams teams with name ${args.options.teamName} found: ${response.value.map(x => x.id)}`);
let found = 0;
response.value.forEach(team => {
if(team.displayName === args.options.teamName){
found++;
teamId = team.id;
}
});
if(found > 1){
return Promise.reject(`Multiple Microsoft Teams teams with name ${args.options.teamName} found: ${response.value.map(x => x.id)}`);
}
}

return Promise.resolve(teamItem.id);
return Promise.resolve(teamId);
});
}

Expand Down