Closed milanholemans closed 2 months ago
LGTM š let's do it š
Can I work on this?
@milanholemans I have noticed that we use an interface ExtendedGroup
to retrieve the Team and confirm that we are trying to execute an action on a Microsoft 365 Team. However, we use the same piece of code for this across 12 commands.
Would it be handy if I put this into a util (or extend the entraGroup util)?
The code that I'm referring to is the following:
private async getTeamId(args: CommandArgs): Promise<string> {
if (args.options.teamId) {
return args.options.teamId;
}
const group = await entraGroup.getGroupByDisplayName(args.options.teamName!);
if ((group as ExtendedGroup).resourceProvisioningOptions.indexOf('Team') === -1) {
throw 'The specified team does not exist in the Microsoft Teams';
}
return group.id!;
}
Same goes for retrieving the channel by the channelName
option, so I think that a teams util could come in handy.
I think it would make sense to centralize ExtendedGroup
instead of copy/pasting it over and over again. Good catch!
About the retrieval of Teams groups and channels by name. I'm all into centralizing this as well. This enables us to throw a uniform error in multiple commands and introduce interactivity when multiple teams with the same name exist. Let's include this in a new teams util. Great suggestions š
Hi @milanholemans
Unfortunately, I have noticed that currently, we haven't got enough permissions to execute the request to the Graph API, as we require the ChannelMessage.ReadWrite
permission to be able to delete a message in a channel.
Is it possible that it gets added to the PnP Application Registration? In the meantime, I will continue developing using my own application.
Yes, be sure to mention this in your PR so we don't forget it.
@milanholemans I think for the refactoring of all the other commands, it might be handy that we create a different issue for this. Otherwise, this PR will become too big I feel.
In that issue, we could possibly also refactor all the commands so that they support both teamId
and teamName
, and channelId
and teamName
, as currently this is quite inconsistent.
Does that seem fine for you?
There are a bunch of commands that lack multiple options like id
and displayName
in Teams. We probably have to split it in multiple issues then.
Makes sense. Let's start with this command, and then continue with the rest I suppose š
Usage
m365 teams message remove [options]
Description
Removes a message from a channel in a Microsoft Teams team
Options
--teamId [teamId]
teamId
orteamName
but not both.--teamName [teamName]
teamId
orteamName
but not both.--channelId [channelId]
channelId
orchannelName
but not both.--channelName [channelName]
channelId
orchannelName
but not both.-i, --id <id>
-f, --force
Examples
Remove a message by using IDs
Remove a message by using display names
Default properties
No response
Additional Info
Remarks:
API: https://learn.microsoft.com/en-us/graph/api/chatmessage-softdelete?view=graph-rest-1.0&tabs=http