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 @@ -49,6 +49,10 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
Expand Down
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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.bot.schema.teams;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* File consent card attachment.
*/
public class FileConsentCard {
/**
* Content type to be used in the type property.
*/
public static final String CONTENT_TYPE = "application/vnd.microsoft.teams.card.file.consent";

@JsonProperty(value = "description")
private String description;

@JsonProperty(value = "sizeInBytes")
private long sizeInBytes;

@JsonProperty(value = "acceptContext")
private Object acceptContext;

@JsonProperty(value = "declineContext")
private Object declineContext;

/**
* Gets file description.
* @return The file description.
*/
public String getDescription() {
return description;
}

/**
* Sets file description.
* @param withDescription The new file description.
*/
public void setDescription(String withDescription) {
description = withDescription;
}

/**
* Gets size of the file to be uploaded in Bytes.
* @return The size in bytes.
*/
public long getSizeInBytes() {
return sizeInBytes;
}

/**
* Sets size of the file to be uploaded in Bytes.
* @param withSizeInBytes The new size in bytes.
*/
public void setSizeInBytes(long withSizeInBytes) {
sizeInBytes = withSizeInBytes;
}

/**
* Gets context sent back to the Bot if user consented to
* upload. This is free flow schema and is sent back in Value field of
* Activity.
* @return The accept context.
*/
public Object getAcceptContext() {
return acceptContext;
}

/**
* Sets context sent back to the Bot if user consented to
* upload. This is free flow schema and is sent back in Value field of
* Activity.
* @param withAcceptContext The new context.
*/
public void setAcceptContext(Object withAcceptContext) {
acceptContext = withAcceptContext;
}

/**
* Gets context sent back to the Bot if user declined. This is
* free flow schema and is sent back in Value field of Activity.
* @return The decline context.
*/
public Object getDeclineContext() {
return declineContext;
}

/**
* Sets context sent back to the Bot if user declined. This is
* free flow schema and is sent back in Value field of Activity.
* @param withDeclineContext The decline context.
*/
public void setDeclineContext(Object withDeclineContext) {
declineContext = withDeclineContext;
}
}
Loading