Share via

Policy Violation GraphAPI

Amit Singh Rawat 731 Reputation points
2024-08-19T13:40:50.39+00:00

I used the following code to apply a policy violation, and it is working fine:

public static void PolicyViolation(string chatId, string messageId)
{
    try
    {
        GraphServiceClient graphClient = StaticVariables.GetGraphServiceClientAsync();

        ChatMessage updatedMessage = new ChatMessage();
        updatedMessage.PolicyViolation = new ChatMessagePolicyViolation()
        {
            PolicyTip = new ChatMessagePolicyViolationPolicyTip()
            {
                GeneralText = "Custom Text to block message",
                MatchedConditionDescriptions = new List<string>() { "Global (Org-wide default)" }
            },
            DlpAction = ChatMessagePolicyViolationDlpActionTypes.BlockAccess,
            VerdictDetails = ChatMessagePolicyViolationVerdictDetailsTypes.AllowFalsePositiveOverride,
        };

        var result1 = graphClient.Chats[chatId].Messages[messageId].PatchAsync(updatedMessage).Result;
        Console.WriteLine("Policy Violation Applied.");
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
}

This code gives me the option to "Report this message and send" within Microsoft Teams, please find snapshot for the same PolicyViolation.png. However, when I do this, I don’t receive any alert or email as an admin.

Where do we receive notifications when a user reports these policy-violated messages to the admin?

Microsoft Security | Microsoft Graph
0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.