Родитель
06e89b94ca
Коммит
8f7bdb6899
|
@ -89,12 +89,6 @@
|
|||
<version>4.6.0-preview9</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20201115</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
package com.microsoft.bot.sample.teamssearchauth;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.microsoft.bot.builder.StatePropertyAccessor;
|
||||
import com.microsoft.bot.builder.TurnContext;
|
||||
import com.microsoft.bot.builder.UserState;
|
||||
|
@ -18,8 +21,6 @@ import okhttp3.Request;
|
|||
import okhttp3.Response;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -133,11 +134,14 @@ public class TeamsMessagingExtensionsSearchAuthConfigBot extends TeamsActivityHa
|
|||
return findPackages(search).thenApply(packages -> {
|
||||
List<MessagingExtensionAttachment> attachments = new ArrayList<>();
|
||||
for (String[] item : packages) {
|
||||
ObjectNode data = Serialization.createObjectNode();
|
||||
data.set("data", Serialization.objectToTree(item));
|
||||
|
||||
ThumbnailCard previewCard = new ThumbnailCard() {{
|
||||
setTitle(item[0]);
|
||||
setTap(new CardAction() {{
|
||||
setType(ActionTypes.INVOKE);
|
||||
setValue(new JSONObject().put("data", item).toString());
|
||||
setValue(data);
|
||||
}});
|
||||
}};
|
||||
|
||||
|
@ -348,21 +352,21 @@ public class TeamsMessagingExtensionsSearchAuthConfigBot extends TeamsActivityHa
|
|||
List<String[]> filteredItems = new ArrayList<String[]>();
|
||||
try {
|
||||
Response response = client.newCall(request).execute();
|
||||
JSONObject obj = new JSONObject(response.body().string());
|
||||
JSONArray dataArray = (JSONArray) obj.get("data");
|
||||
JsonNode obj = Serialization.jsonToTree(response.body().string());
|
||||
ArrayNode dataArray = (ArrayNode) obj.get("data");
|
||||
|
||||
dataArray.forEach(i -> {
|
||||
JSONObject item = (JSONObject) i;
|
||||
for (int i = 0; i < dataArray.size(); i++) {
|
||||
JsonNode item = dataArray.get(i);
|
||||
filteredItems.add(
|
||||
new String[]{
|
||||
item.getString("id"), item.getString("version"),
|
||||
item.getString("description"),
|
||||
item.has("projectUrl") ? item.getString("projectUrl") : "",
|
||||
item.has("iconUrl") ? item.getString("iconUrl") : ""
|
||||
new String[] {
|
||||
item.get("id").asText(),
|
||||
item.get("version").asText(),
|
||||
item.get("description").asText(),
|
||||
item.has("projectUrl") ? item.get("projectUrl").asText() : "",
|
||||
item.has("iconUrl") ? item.get("iconUrl").asText() : ""
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LoggerFactory.getLogger(TeamsMessagingExtensionsSearchAuthConfigBot.class)
|
||||
.error("findPackages", e);
|
||||
|
|
Загрузка…
Ссылка в новой задаче