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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import com.microsoft.bot.schema.teams.MessagingExtensionQuery;
import com.microsoft.bot.schema.teams.MessagingExtensionResponse;
import com.microsoft.bot.schema.teams.O365ConnectorCardActionQuery;
import com.microsoft.bot.schema.teams.TabRequest;
import com.microsoft.bot.schema.teams.TabResponse;
import com.microsoft.bot.schema.teams.TabSubmit;
import com.microsoft.bot.schema.teams.TaskModuleRequest;
import com.microsoft.bot.schema.teams.TaskModuleResponse;
import com.microsoft.bot.schema.teams.TeamInfo;
Expand All @@ -42,7 +45,7 @@
* Pre and post processing of Activities can be plugged in by deriving and
* calling the base class implementation.
*/
@SuppressWarnings({ "checkstyle:JavadocMethod", "checkstyle:DesignForExtension" })
@SuppressWarnings({ "checkstyle:JavadocMethod", "checkstyle:DesignForExtension", "checkstyle:MethodLength" })
public class TeamsActivityHandler extends ActivityHandler {
/**
* Invoked when an invoke activity is received from the connector when the base
Expand Down Expand Up @@ -174,6 +177,26 @@ protected CompletableFuture<InvokeResponse> onInvokeActivity(TurnContext turnCon
).thenApply(ActivityHandler::createInvokeResponse);
break;

case "tab/fetch":
result = onTeamsTabFetch(
turnContext,
Serialization.safeGetAs(
turnContext.getActivity().getValue(),
TabRequest.class
)
).thenApply(ActivityHandler::createInvokeResponse);
break;

case "tab/submit":
result = onTeamsTabSubmit(
turnContext,
Serialization.safeGetAs(
turnContext.getActivity().getValue(),
TabSubmit.class
)
).thenApply(ActivityHandler::createInvokeResponse);
break;

default:
result = super.onInvokeActivity(turnContext);
break;
Expand Down Expand Up @@ -484,7 +507,8 @@ protected CompletableFuture<TaskModuleResponse> onTeamsTaskModuleFetch(
}

/**
* Override this in a derived class to provide logic for when a card button is clicked in a messaging extension.
* Override this in a derived class to provide logic for when a card button
* is clicked in a messaging extension.
*
* @param turnContext The current TurnContext.
* @param cardData Object representing the card data.
Expand Down Expand Up @@ -676,8 +700,8 @@ protected CompletableFuture<Void> onTeamsMembersAddedDispatch(
}

if (teamsChannelAccount == null) {
// unable to find the member added in ConversationUpdate Activity in the response from the
// getMember call
// unable to find the member added in ConversationUpdate Activity in
// the response from the getMember call
teamsChannelAccount = new TeamsChannelAccount();
teamsChannelAccount.setId(memberAdded.getId());
teamsChannelAccount.setName(memberAdded.getName());
Expand Down Expand Up @@ -919,6 +943,26 @@ protected CompletableFuture<Void> onTeamsTeamUnarchived(
return CompletableFuture.completedFuture(null);
}

/**
* Override this in a derived class to provide logic for when a tab is fetched.
* @param turnContext The context object for this turn.
* @param tabRequest The tab invoke request value payload.
* @return A Tab Response for the request.
*/
protected CompletableFuture<TabResponse> onTeamsTabFetch(TurnContext turnContext, TabRequest tabRequest) {
return withException(new InvokeResponseException(HttpURLConnection.HTTP_NOT_IMPLEMENTED));
}

/**
* Override this in a derived class to provide logic for when a tab is submitted.
* @param turnContext The context object for this turn.
* @param tabSubmit The tab submit invoke request value payload.
* @return A Tab Response for the request.
*/
protected CompletableFuture<TabResponse> onTeamsTabSubmit(TurnContext turnContext, TabSubmit tabSubmit) {
return withException(new InvokeResponseException(HttpURLConnection.HTTP_NOT_IMPLEMENTED));
}

/**
* Invoke a new InvokeResponseException with a HTTP 501 code status.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.bot.schema.teams;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Current tab request context, i.e., the current theme.
*/
public class TabContext {
@JsonProperty(value = "theme")
private String theme;

/**
* Initializes a new instance of the class.
*/
public TabContext() {

}

/**
* Initializes a new instance of the class.
* @param withTheme The current user's theme.
*/
public TabContext(String withTheme) {
theme = withTheme;
}

/**
* Gets the current user's theme.
* @return The current user's theme.
*/
public String getTheme() {
return theme;
}

/**
* Sets the current user's theme.
* @param withTheme The current user's theme.
*/
public void setTheme(String withTheme) {
theme = withTheme;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.bot.schema.teams;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Current TabRequest entity context, or 'tabEntityId'.
*/
public class TabEntityContext {
@JsonProperty(value = "tabEntityId")
private String tabEntityId;

/**
* Initializes a new instance of the class.
*/
public TabEntityContext() {

}

/**
* Initializes a new instance of the class.
* @param withTabEntityId The entity id of the tab.
*/
public TabEntityContext(String withTabEntityId) {
tabEntityId = withTabEntityId;
}

/**
* Gets the entity id of the tab.
* @return The entity id of the tab.
*/
public String getTabEntityId() {
return tabEntityId;
}

/**
* Sets the entity id of the tab.
* @param withTabEntityId The entity id of the tab.
*/
public void setTabEntityId(String withTabEntityId) {
tabEntityId = withTabEntityId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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 ('tab/fetch') request value payload.
*/
public class TabRequest {
@JsonProperty(value = "tabContext")
private TabEntityContext tabContext;

@JsonProperty(value = "context")
private TabContext context;

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

/**
* Initializes a new instance of the class.
*/
public TabRequest() {

}

/**
* Gets current tab entity request context.
* @return Tab context
*/
public TabEntityContext getTabContext() {
return tabContext;
}

/**
* Sets current tab entity request context.
* @param withTabContext Tab context
*/
public void setTabContext(TabEntityContext withTabContext) {
tabContext = withTabContext;
}

/**
* Gets current user context, i.e., the current theme.
* @return Current user context, i.e., the current theme.
*/
public TabContext getContext() {
return context;
}

/**
* Sets current user context, i.e., the current theme.
* @param withContext Current user context, i.e., the current theme.
*/
public void setContext(TabContext withContext) {
context = withContext;
}

/**
* Gets state, which is the magic code for OAuth Flow.
* @return State, which is the magic code for OAuth Flow.
*/
public String getState() {
return state;
}

/**
* Sets state, which is the magic code for OAuth Flow.
* @param withState State, which is the magic code for OAuth Flow.
*/
public void setState(String withState) {
state = withState;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.bot.schema.teams;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Envelope for Card Tab Response Payload.
*/
public class TabResponse {
@JsonProperty(value = "tab")
private TabResponsePayload tab;

/**
* Initializes a new instance of the class.
*/
public TabResponse() {

}

/**
* Gets the response to the tab/fetch message.
* @return Cards in response to a TabRequest.
*/
public TabResponsePayload getTab() {
return tab;
}

/**
* Sets the response to the tab/fetch message.
* @param withTab Cards in response to a TabRequest.
*/
public void setTab(TabResponsePayload withTab) {
tab = withTab;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.bot.schema.teams;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Envelope for cards for a Tab request.
*/
public class TabResponseCard {
@JsonProperty(value = "card")
private Object card;

/**
* Initializes a new instance of the class.
*/
public TabResponseCard() {

}

/**
* Gets adaptive card for this card tab response.
* @return Cards for this TabResponse.
*/
public Object getCard() {
return card;
}

/**
* Sets adaptive card for this card tab response.
* @param withCard Cards for this TabResponse.
*/
public void setCard(Object withCard) {
card = withCard;
}
}
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;
import java.util.List;

/**
* Envelope for cards for a TabResponse.
*/
public class TabResponseCards {
@JsonProperty(value = "cards")
private List<Object> cards;

/**
* Initializes a new instance of the class.
*/
public TabResponseCards() {

}

/**
* Gets adaptive cards for this card tab response.
* @return Cards for the TabResponse.
*/
public List<Object> getCards() {
return cards;
}

/**
* Sets adaptive cards for this card tab response.
* @param withCards Cards for the TabResponse.
*/
public void setCards(List<Object> withCards) {
cards = withCards;
}
}
Loading