Browse Source
* PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * UI: Change configuration Microsoft Team recipient config * UI: Add null check in Microsoft Team recipient config * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * PROD-4064: Migrate from Office 365 Connectors to Microsoft Teams Workflows. Replace MessageCard by AdaptiveCard * Resolved PR comments * Resolved PR comments --------- Co-authored-by: sskoryi <sskoryi@thingsboard.io> Co-authored-by: Vladyslav_Prykhodko <vprykhodko@thingsboard.io>pull/11644/head
committed by
GitHub
10 changed files with 470 additions and 95 deletions
@ -0,0 +1,93 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.service.notification.channels; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
import org.thingsboard.server.dao.util.ImageUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @link <a href="https://adaptivecards.io/designer/">AdaptiveCard Designer</a> |
|||
*/ |
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class TeamsAdaptiveCard { |
|||
private String type = "message"; |
|||
private List<Attachment> attachments; |
|||
|
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public static class Attachment { |
|||
private String contentType = "application/vnd.microsoft.card.adaptive"; |
|||
private AdaptiveCard content; |
|||
} |
|||
|
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public static class AdaptiveCard { |
|||
@JsonProperty("$schema") |
|||
private final String schema = "http://adaptivecards.io/schemas/adaptive-card.json"; |
|||
private final String type = "AdaptiveCard"; |
|||
private BackgroundImage backgroundImage; |
|||
@JsonProperty("body") |
|||
private List<TextBlock> textBlocks = new ArrayList<>(); |
|||
private List<ActionOpenUrl> actions = new ArrayList<>(); |
|||
} |
|||
|
|||
@Data |
|||
@NoArgsConstructor |
|||
public static class BackgroundImage { |
|||
private String url; |
|||
private final String fillMode = "repeat"; |
|||
|
|||
public BackgroundImage(String color) { |
|||
// This is the only one way how to specify color the custom color for the card
|
|||
url = ImageUtils.getEmbeddedBase64EncodedImg(color); |
|||
} |
|||
|
|||
} |
|||
|
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public static class TextBlock { |
|||
private final String type = "TextBlock"; |
|||
private String text; |
|||
private String weight = "Normal"; |
|||
private String size = "Medium"; |
|||
private String spacing = "None"; |
|||
private String color = "#FFFFFF"; |
|||
private final boolean wrap = true; |
|||
} |
|||
|
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public static class ActionOpenUrl { |
|||
private final String type = "Action.OpenUrl"; |
|||
private String title; |
|||
private String url; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.service.notification.channels; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
public class TeamsMessageCard { |
|||
@JsonProperty("@type") |
|||
private final String type = "MessageCard"; |
|||
@JsonProperty("@context") |
|||
private final String context = "http://schema.org/extensions"; |
|||
private String themeColor; |
|||
private String summary; |
|||
private String text; |
|||
private List<Section> sections; |
|||
private List<ActionCard> potentialAction; |
|||
|
|||
@Data |
|||
public static class Section { |
|||
private String activityTitle; |
|||
private String activitySubtitle; |
|||
private String activityImage; |
|||
private List<Fact> facts; |
|||
private boolean markdown; |
|||
|
|||
@Data |
|||
public static class Fact { |
|||
private final String name; |
|||
private final String value; |
|||
} |
|||
} |
|||
|
|||
@Data |
|||
@JsonInclude(JsonInclude.Include.NON_NULL) |
|||
public static class ActionCard { |
|||
@JsonProperty("@type") |
|||
private String type; // ActionCard, OpenUri
|
|||
private String name; |
|||
private List<Input> inputs; // for ActionCard
|
|||
private List<Action> actions; // for ActionCard
|
|||
private List<Target> targets; |
|||
|
|||
@Data |
|||
public static class Input { |
|||
@JsonProperty("@type") |
|||
private String type; // TextInput, DateInput, MultichoiceInput
|
|||
private String id; |
|||
private boolean isMultiple; |
|||
private String title; |
|||
private boolean isMultiSelect; |
|||
|
|||
@Data |
|||
public static class Choice { |
|||
private final String display; |
|||
private final String value; |
|||
} |
|||
} |
|||
|
|||
@Data |
|||
public static class Action { |
|||
@JsonProperty("@type") |
|||
private final String type; // HttpPOST
|
|||
private final String name; |
|||
private final String target; // url
|
|||
} |
|||
|
|||
@Data |
|||
public static class Target { |
|||
private final String os; |
|||
private final String uri; |
|||
} |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue