microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
docs/update-release-process

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

core/src/Microsoft.Teams.Apps/Handlers/ConversationUpdateHandler.Activity.cs

164lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4using System.Text.Json.Serialization;
5using Microsoft.Teams.Apps.Schema;
6using Microsoft.Teams.Core.Schema;
7
8namespace Microsoft.Teams.Apps.Handlers;
9
10/// <summary>
11/// Represents a conversation update activity.
12/// </summary>
13public class ConversationUpdateActivity : TeamsActivity
14{
15 /// <summary>
16 /// Convenience method to create a ConversationUpdateActivity from a CoreActivity.
17 /// </summary>
18 /// <param name="activity">The CoreActivity to convert.</param>
19 /// <returns>A ConversationUpdateActivity instance.</returns>
20 public static new ConversationUpdateActivity FromActivity(CoreActivity activity)
21 {
22 ArgumentNullException.ThrowIfNull(activity);
23 return new ConversationUpdateActivity(activity);
24 }
25
26 /// <summary>
27 /// Default constructor.
28 /// </summary>
29 [JsonConstructor]
30 public ConversationUpdateActivity() : base(TeamsActivityTypes.ConversationUpdate)
31 {
32 }
33
34 /// <summary>
35 /// Internal constructor to create ConversationUpdateActivity from CoreActivity.
36 /// </summary>
37 /// <param name="activity">The CoreActivity to convert.</param>
38 protected ConversationUpdateActivity(CoreActivity activity) : base(activity)
39 {
40 /*
41 if (activity.Properties.TryGetValue("topicName", out var topicName))
42 {
43 TopicName = topicName?.ToString();
44 activity.Properties.Remove("topicName");
45 }
46 */
47
48 MembersAdded = activity.Properties.Extract<IList<TeamsChannelAccount>>("membersAdded");
49 MembersRemoved = activity.Properties.Extract<IList<TeamsChannelAccount>>("membersRemoved");
50 }
51
52 //TODO : review properties
53 /*
54 /// <summary>
55 /// Gets or sets the updated topic name of the conversation.
56 /// </summary>
57 [JsonPropertyName("topicName")]
58 public string? TopicName { get; set; }
59 */
60
61 /// <summary>
62 /// Gets or sets the collection of members added to the conversation.
63 /// </summary>
64 [JsonPropertyName("membersAdded")]
65 public IList<TeamsChannelAccount>? MembersAdded { get; set; }
66
67 /// <summary>
68 /// Gets or sets the collection of members removed from the conversation.
69 /// </summary>
70 [JsonPropertyName("membersRemoved")]
71 public IList<TeamsChannelAccount>? MembersRemoved { get; set; }
72}
73
74/// <summary>
75/// String constants for conversation event types.
76/// </summary>
77public static class ConversationEventTypes
78{
79 /// <summary>
80 /// Channel created event.
81 /// </summary>
82 public const string ChannelCreated = "channelCreated";
83
84 /// <summary>
85 /// Channel deleted event.
86 /// </summary>
87 public const string ChannelDeleted = "channelDeleted";
88
89 /// <summary>
90 /// Channel renamed event.
91 /// </summary>
92 public const string ChannelRenamed = "channelRenamed";
93
94
95 /// <summary>
96 /// Channel shared event.
97 /// </summary>
98 public const string ChannelShared = "channelShared";
99
100 /// <summary>
101 /// Channel unshared event.
102 /// </summary>
103 public const string ChannelUnShared = "channelUnshared";
104
105 /// <summary>
106 /// Channel member added event.
107 /// </summary>
108 public const string ChannelMemberAdded = "channelMemberAdded";
109
110 /// <summary>
111 /// Channel member removed event.
112 /// </summary>
113 public const string ChannelMemberRemoved = "channelMemberRemoved";
114
115 //TODO : review these events
116 /*
117 /// <summary>
118 /// Channel restored event.
119 /// </summary>
120 public const string ChannelRestored = "channelRestored";
121 */
122
123 /// <summary>
124 /// Team member added event.
125 /// </summary>
126 public const string TeamMemberAdded = "teamMemberAdded";
127
128 /// <summary>
129 /// Team member removed event.
130 /// </summary>
131 public const string TeamMemberRemoved = "teamMemberRemoved";
132
133 /// <summary>
134 /// Team archived event.
135 /// </summary>
136 public const string TeamArchived = "teamArchived";
137
138 /// <summary>
139 /// Team deleted event.
140 /// </summary>
141 public const string TeamDeleted = "teamDeleted";
142
143 /// <summary>
144 /// Team renamed event.
145 /// </summary>
146 public const string TeamRenamed = "teamRenamed";
147
148 /// <summary>
149 /// Team unarchived event.
150 /// </summary>
151 public const string TeamUnarchived = "teamUnarchived";
152
153 /*TODO : review these events
154 /// <summary>
155 /// Team hard deleted event.
156 /// </summary>
157 public const string TeamHardDeleted = "teamHardDeleted";
158
159 /// <summary>
160 /// Team restored event.
161 /// </summary>
162 public const string TeamRestored = "teamRestored";
163 */
164}
165