Teams botbuilder-schema by tracyboehrer · Pull Request #395 · microsoft/botbuilder-java · GitHub
Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libraries/bot-schema/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ public enum ActionTypes {
/**
* Enum value messageBack.
*/
MESSAGE_BACK("messageBack");
MESSAGE_BACK("messageBack"),

/**
* Enum value invoke.
*/
INVOKE("invoke");

/**
* The actual serialized value for a ActionTypes instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

package com.microsoft.bot.schema;

import com.microsoft.bot.schema.teams.TeamsChannelData;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonFormat;
Expand Down Expand Up @@ -1504,4 +1506,44 @@ public static String removeMentionTextImmutable(Activity activity, String id) {

return text;
}

/**
* Check if this actvity is from microsoft teams.
* @return true if the activity is from microsoft teams.
*/
public boolean isTeamsActivity() {
return "msteams".equals(channelId);
}

/**
* Get unique identifier representing a channel.
*
* @throws JsonProcessingException when channel data can't be parsed to TeamChannelData
* @return Unique identifier representing a channel
*/
public String teamsGetChannelId() throws JsonProcessingException {
TeamsChannelData teamsChannelData = getChannelData(TeamsChannelData.class);
String teamsChannelId = teamsChannelData.getTeamsChannelId();
if (teamsChannelId == null && teamsChannelData.getChannel() != null) {
teamsChannelId = teamsChannelData.getChannel().getId();
}

return teamsChannelId;
}

/**
* Get unique identifier representing a team.
*
* @throws JsonProcessingException when channel data can't be parsed to TeamChannelData
* @return Unique identifier representing a team.
*/
public String teamsGetTeamId() throws JsonProcessingException {
TeamsChannelData teamsChannelData = getChannelData(TeamsChannelData.class);
String teamId = teamsChannelData.getTeamsTeamId();
if (teamId == null && teamsChannelData.getTeam() != null) {
teamId = teamsChannelData.getTeam().getId();
}

return teamId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.bot.schema.teams;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Invoke request body type for app-based link query.
*/
public class AppBasedLinkQuery {
@JsonProperty(value = "url")
private String url;

/**
* Initializes a new instance of the AppBasedLinkQuery class.
* @param withUrl The query url.
*/
public AppBasedLinkQuery(String withUrl) {
url = withUrl;
}

/**
* Gets url queried by user.
* @return The url
*/
public String getUrl() {
return url;
}

/**
* Sets url queried by user.
* @param withUrl The url.
*/
public void setUrl(String withUrl) {
url = withUrl;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.bot.schema.teams;

import com.microsoft.bot.schema.Attachment;

/**
* Attachment extensions.
*/
public final class AttachmentExtensions {
private AttachmentExtensions() { }

/**
* Converts normal attachment into the messaging extension attachment.
* @param attachment The Attachment.
* @param previewAttachment The preview Attachment.
* @return Messaging extension attachment.
*/
public static MessagingExtensionAttachment toMessagingExtensionAttachment(
Attachment attachment,
Attachment previewAttachment) {

MessagingExtensionAttachment messagingAttachment = new MessagingExtensionAttachment();
messagingAttachment.setContent(attachment.getContent());
messagingAttachment.setContentType(attachment.getContentType());
messagingAttachment.setContentUrl(attachment.getContentUrl());
messagingAttachment.setName(attachment.getName());
messagingAttachment.setThumbnailUrl(attachment.getThumbnailUrl());
messagingAttachment.setPreview(previewAttachment == null ? Attachment.clone(attachment) : previewAttachment);

return messagingAttachment;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.bot.schema.teams;

import com.fasterxml.jackson.annotation.JsonProperty;


/**
* A channel info object which describes the channel.
*/
public class ChannelInfo {
@JsonProperty(value = "id")
private String id;

/**
* name of the channel.
*/
@JsonProperty(value = "name")
private String name;

/**
* Get the unique identifier representing a channel.
*
* @return the unique identifier representing a channel.
*/
public final String getId() {
return id;
}

/**
* Set unique identifier representing a channel.
*
* @param withId the unique identifier representing a channel.
*/
public void setId(String withId) {
this.id = withId;
}

/**
* Get the name of the channel.
*
* @return name of the channel.
*/
public String getName() {
return name;
}

/**
* Sets name of the channel.
*
* @param withName the name of the channel.
*/
public void setName(String withName) {
this.name = withName;
}

/**
* Initializes a new instance of the ChannelInfo class.
*
* @param withId identifier representing a channel.
* @param withName Name of the channel.
*/
public ChannelInfo(String withId, String withName) {
this.id = withId;
this.name = withName;
}

/**
* Initializes a new instance of the ChannelInfo class.
*/
public ChannelInfo() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.bot.schema.teams;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

/**
* List of channels under a team.
*/
public class ConversationList {
@JsonProperty(value = "conversations")
private List<ChannelInfo> conversations;

/**
* Gets the list of conversations.
* @return The list of conversations.
*/
public List<ChannelInfo> getConversations() {
return conversations;
}

/**
* Sets the list of conversations.
* @param withConversations The new list of conversations.
*/
public void setConversations(List<ChannelInfo> withConversations) {
conversations = withConversations;
}
}
Loading