private bool IsTeamInformationUpdated(IConversationUpdateActivity activity) { if (activity == null) { return(false); } var channelData = activity.GetChannelData <TeamsChannelData>(); if (channelData == null) { return(false); } return(CompanyCommunicatorBot.TeamRenamedEventType.Equals(channelData.EventType, StringComparison.OrdinalIgnoreCase)); }
private static TeamDataEntity ParseTeamData(IConversationUpdateActivity activity) { var channelData = activity.GetChannelData <TeamsChannelData>(); if (channelData != null) { var teamsDataEntity = new TeamDataEntity { PartitionKey = PartitionKeyNames.TeamDataTable.TeamDataPartition, RowKey = channelData.Team.Id, TeamId = channelData.Team.Id, Name = channelData.Team.Name, ServiceUrl = activity.ServiceUrl, TenantId = channelData.Tenant.Id, }; return(teamsDataEntity); } return(null); }
/// <summary>Gets the conversation update data.</summary> /// <param name="activity">The activity.</param> /// <returns>Channel event data.</returns> /// <exception cref="Exception"> /// Failed to process channel data in Activity /// or /// ChannelData missing in Activity /// </exception> public static TeamEventBase GetConversationUpdateData(this IConversationUpdateActivity activity) { if (activity.GetActivityType() != ActivityTypes.ConversationUpdate) { throw new ArgumentException("activity must be a ConversationUpdate"); } if (activity.ChannelData != null) { TeamsChannelData channelData = activity.GetChannelData <TeamsChannelData>(); if (!string.IsNullOrEmpty(channelData?.EventType)) { switch (channelData.EventType) { case MembersAddedEventName: return(new MembersAddedEvent { MembersAdded = activity.MembersAdded, Team = channelData.Team, Tenant = channelData.Tenant }); case MembersRemovedEventName: return(new MembersRemovedEvent { MembersRemoved = activity.MembersRemoved, Team = channelData.Team, Tenant = channelData.Tenant }); case ChannelCreatedEventName: return(new ChannelCreatedEvent { Channel = channelData.Channel, Team = channelData.Team, Tenant = channelData.Tenant }); case ChannelDeletedEventName: return(new ChannelDeletedEvent { Channel = channelData.Channel, Team = channelData.Team, Tenant = channelData.Tenant }); case ChannelRenamedEventName: return(new ChannelRenamedEvent { Channel = channelData.Channel, Team = channelData.Team, Tenant = channelData.Tenant }); case TeamRenamedEventName: return(new TeamRenamedEvent { Tenant = channelData.Tenant, Team = channelData.Team }); } } throw new ArgumentException("Failed to process channel data in Activity"); } else { throw new ArgumentNullException("Activity.ChannelData", "ChannelData missing in Activity"); } }