Skip to content

Commit

Permalink
Merge branch 'release/0.42.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ljupcovangelski committed Apr 7, 2022
2 parents 9a2b2f0 + 219fff4 commit 1a54507
Show file tree
Hide file tree
Showing 267 changed files with 9,133 additions and 7,364 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release Drafter
on:
push:
branches:
- release/*
- changelog/*

jobs:
update_release_draft:
Expand Down
2 changes: 1 addition & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@com_github_airyhq_bazel_tools//lint:buildifier.bzl", "check_pkg")
load("@com_github_airyhq_bazel_tools//lint:prettier.bzl", "fix_prettier")
load("@rules_java//java:defs.bzl", "java_library", "java_plugin")
load("@io_bazel_rules_docker//container:container.bzl", "container_image")
load("@com_github_atlassian_bazel_tools//multirun:def.bzl", "multirun")
load("@com_github_ash2k_bazel_tools//multirun:def.bzl", "multirun")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@io_bazel_rules_go//go:def.bzl", "TOOLS_NOGO", "nogo")

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.41.0
0.42.0
40 changes: 24 additions & 16 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
# Airy Bazel tools
git_repository(
name = "com_github_airyhq_bazel_tools",
commit = "7be57ca7d9b8b716e8ca8c8af0d5d6945e4a6d06",
commit = "594a0ec552998293674edff959ce8c782683faef",
remote = "https://github.com/airyhq/bazel-tools.git",
shallow_since = "1647017998 +0100",
shallow_since = "1649147253 +0200",
)

load("@com_github_airyhq_bazel_tools//:repositories.bzl", "airy_bazel_tools_dependencies", "airy_jvm_deps")
Expand All @@ -26,6 +26,7 @@ load("//:repositories.bzl", "excluded_artifacts", jvm_deps = "airy_jvm_deps")
maven_install(
artifacts = airy_jvm_deps + jvm_deps,
excluded_artifacts = excluded_artifacts,
fail_if_repin_required = True,
maven_install_json = "//:maven_install.json",
repositories = [
"https://packages.confluent.io/maven",
Expand All @@ -49,6 +50,17 @@ http_archive(
],
)

http_archive(
name = "zlib",
build_file = "@com_google_protobuf//:third_party/zlib.BUILD",
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
strip_prefix = "zlib-1.2.11",
urls = [
"https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz",
"https://zlib.net/zlib-1.2.11.tar.gz",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()
Expand All @@ -66,13 +78,6 @@ load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

gazelle_dependencies()

git_repository(
name = "com_google_protobuf",
commit = "09745575a923640154bcf307fba8aedff47f240a",
remote = "https://github.com/protocolbuffers/protobuf",
shallow_since = "1558721209 -0700",
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()
Expand All @@ -81,9 +86,9 @@ protobuf_deps()

http_archive(
name = "io_bazel_rules_docker",
sha256 = "59d5b42ac315e7eadffa944e86e90c2990110a1c8075f1cd145f487e999d22b3",
strip_prefix = "rules_docker-0.17.0",
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.17.0/rules_docker-v0.17.0.tar.gz"],
sha256 = "85ffff62a4c22a74dbd98d05da6cf40f497344b3dbf1e1ab0a37ab2a1a6ca014",
strip_prefix = "rules_docker-0.23.0",
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.23.0/rules_docker-v0.23.0.tar.gz"],
)

load(
Expand Down Expand Up @@ -134,6 +139,9 @@ load(
_go_image_repos()

### Frontend build tooling
load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")

build_bazel_rules_nodejs_dependencies()

load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")

Expand All @@ -148,13 +156,13 @@ yarn_install(
### Bazel tooling

git_repository(
name = "com_github_atlassian_bazel_tools",
commit = "e45e55f213b6804115eed1b6eb4ffc3bcf7a0cc4",
name = "com_github_ash2k_bazel_tools",
commit = "aefb11464b6b83590e4154a98c29171092ca290f",
remote = "https://github.com/ash2k/bazel-tools.git",
shallow_since = "1614900742 +1100",
shallow_since = "1644872739 +1100",
)

load("@com_github_atlassian_bazel_tools//multirun:deps.bzl", "multirun_dependencies")
load("@com_github_ash2k_bazel_tools//multirun:deps.bzl", "multirun_dependencies")

multirun_dependencies()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,36 @@

import co.airy.core.api.config.payload.ClientConfigResponsePayload;
import co.airy.spring.auth.PrincipalAccess;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

@RestController
public class ClientConfigController {
private final ServiceDiscovery serviceDiscovery;
private final PrincipalAccess principalAccess;
private final JsonNode tagConfig;

public ClientConfigController(ServiceDiscovery serviceDiscovery, PrincipalAccess principalAccess) {
public ClientConfigController(ServiceDiscovery serviceDiscovery, PrincipalAccess principalAccess) throws IOException {
this.serviceDiscovery = serviceDiscovery;
this.principalAccess = principalAccess;
final String tagConfigResource = StreamUtils.copyToString(getClass().getClassLoader().getResourceAsStream("tagConfig.json"), StandardCharsets.UTF_8);
this.tagConfig = new ObjectMapper().readTree(tagConfigResource);
}

@PostMapping("/client.config")
public ResponseEntity<ClientConfigResponsePayload> getConfig(Authentication auth) {
return ResponseEntity.ok(ClientConfigResponsePayload.builder()
.services(serviceDiscovery.getServices())
.userProfile(principalAccess.getUserProfile(auth))
.tagConfig(tagConfig)
.build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import co.airy.core.api.config.dto.ServiceInfo;
import co.airy.spring.auth.session.UserProfile;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -16,4 +17,5 @@
public class ClientConfigResponsePayload {
private Map<String, ServiceInfo> services;
private UserProfile userProfile;
private JsonNode tagConfig;
}
32 changes: 32 additions & 0 deletions backend/api/admin/src/main/resources/tagConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"colors": {
"tag-green": {
"default": "0E764F",
"background": "F5FFFB",
"font": "0E764F",
"position": 3,
"border": "0E764F"
},
"tag-blue": {
"default": "1578D4",
"background": "F5FFFB",
"font": "1578D4",
"position": 1,
"border": "1578D4"
},
"tag-red": {
"default": "E0243A",
"background": "FFF7F9",
"font": "E0243A",
"position": 2,
"border": "E0243A"
},
"tag-purple": {
"default": "730A80",
"background": "FEF7FF",
"font": "730A80",
"position": 4,
"border": "730A80"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void beforeEach() throws Exception {
}

@Test
public void canReturnConfig() throws Exception {
public void canReturnConfigServices() throws Exception {
mockServer.expect(once(), requestTo(new URI("http://airy-controller.default/services")))
.andExpect(method(HttpMethod.GET))
.andRespond(
Expand All @@ -87,14 +87,24 @@ public void canReturnConfig() throws Exception {
withSuccess("{\"status\": \"DOWN\"}", MediaType.APPLICATION_JSON)
);

retryOnException(() -> webTestHelper.post("/client.config", "{}")
.andExpect(status().isOk())
.andExpect(jsonPath("$.services.*", hasSize(1)))
.andExpect(jsonPath("$.services", hasKey("api-communication")))
.andExpect(jsonPath("$.services.*.enabled", everyItem(is(true))))
.andExpect(jsonPath("$.services.*.healthy", everyItem(is(false)))),
"client.config call failed");

retryOnException(() ->
webTestHelper.post("/client.config", "{}")
.andExpect(status().isOk())
.andExpect(jsonPath("$.services.*", hasSize(1)))
.andExpect(jsonPath("$.services", hasKey("api-communication")))
.andExpect(jsonPath("$.services.*.enabled", everyItem(is(true))))
.andExpect(jsonPath("$.services.*.healthy", everyItem(is(false))))
.andExpect(jsonPath("$.tag_config.*", hasSize(1)))
.andExpect(jsonPath("$.tag_config", hasKey("colors")))
.andExpect(jsonPath("$.tag_config.colors", hasKey("tag-green")))
.andExpect(jsonPath("$.tag_config.colors.tag-green.*", hasSize(5)))
.andExpect(jsonPath("$.tag_config.colors", hasKey("tag-blue")))
.andExpect(jsonPath("$.tag_config.colors.tag-blue.*", hasSize(5)))
.andExpect(jsonPath("$.tag_config.colors", hasKey("tag-red")))
.andExpect(jsonPath("$.tag_config.colors.tag-red.*", hasSize(5)))
.andExpect(jsonPath("$.tag_config.colors", hasKey("tag-purple")))
.andExpect(jsonPath("$.tag_config.colors.tag-purple.*", hasSize(5))),
"client.config call failed for services");
mockServer.verify();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package co.airy.core.api.communication;

import co.airy.avro.communication.Metadata;
import co.airy.avro.communication.ValueType;
import co.airy.core.api.communication.payload.MessageListRequestPayload;
import co.airy.core.api.communication.payload.MessageListResponsePayload;
import co.airy.core.api.communication.payload.MessageSuggestRepliesRequestPayload;
Expand Down Expand Up @@ -86,6 +87,7 @@ ResponseEntity<?> messageSuggestReplies(@RequestBody @Valid MessageSuggestReplie
final Metadata metadata = newMessageMetadata(messageId,
String.format("%s.%s.content", SUGGESTIONS, entry.getKey()),
objectMapper.writeValueAsString(entry.getValue().getContent()));
metadata.setValueType(ValueType.object);
container.getMetadataMap().put(metadata.getKey(), metadata);
stores.storeMetadata(metadata);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import co.airy.avro.communication.Metadata;
import co.airy.avro.communication.ReadReceipt;
import co.airy.avro.communication.User;
import co.airy.avro.communication.ValueType;
import co.airy.core.api.communication.dto.CountAction;
import co.airy.core.api.communication.dto.Messages;
import co.airy.core.api.communication.dto.UnreadCountState;
Expand Down Expand Up @@ -127,6 +128,7 @@ private void startStream() {
.map((conversationId, unreadCountState) -> {
final Metadata metadata = newConversationMetadata(conversationId, MetadataKeys.ConversationKeys.UNREAD_COUNT,
unreadCountState.getUnreadCount().toString());
metadata.setValueType(ValueType.number);
return KeyValue.pair(getId(metadata).toString(), metadata);
})
.to(applicationCommunicationMetadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class ConversationIndex implements Serializable {

public static ConversationIndex fromConversation(Conversation conversation) {
final List<MetadataNode> metadataNodes = conversation.getMetadataMap().values().stream()
.map((record) -> new MetadataNode(record.getKey(), record.getValue()))
.map((record) -> new MetadataNode(record.getKey(), record.getValue(), record.getValueType()))
.collect(Collectors.toList());

return ConversationIndex.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static co.airy.core.api.communication.util.Topics.applicationCommunicationChannels;
import static co.airy.core.api.communication.util.Topics.getTopics;
import static co.airy.test.Timing.retryOnException;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.core.Is.is;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
Expand Down Expand Up @@ -77,9 +78,10 @@ void canUpsertMetadata() throws Exception {
kafkaTestHelper.produceRecords(producerRecords);
final String messageId = producerRecords.get(0).key();

// Test object, number, and list metadata
retryOnException(
() -> webTestHelper.post("/metadata.upsert",
"{\"subject\": \"message\", \"id\": \"" + messageId + "\", \"data\": {\"sentFrom\": \"iPhone\"}}")
"{\"subject\": \"message\", \"id\": \"" + messageId + "\", \"data\": {\"seq\":42, \"sentFrom\": \"iPhone\",\"assignees\": [\"Alice\",\"Bob\"]}}")
.andExpect(status().isNoContent()),
"Error upserting metadata"
);
Expand All @@ -88,15 +90,10 @@ void canUpsertMetadata() throws Exception {
() -> webTestHelper.post("/conversations.info",
"{\"conversation_id\":\"" + conversationId + "\"}")
.andExpect(status().isOk())
.andExpect(jsonPath("$.last_message.metadata.user_data.sentFrom", is("iPhone"))),
.andExpect(jsonPath("$.last_message.metadata.user_data.sentFrom", is("iPhone")))
.andExpect(jsonPath("$.last_message.metadata.user_data.assignees").value(containsInAnyOrder("Alice", "Bob")))
.andExpect(jsonPath("$.last_message.metadata.user_data.seq", is(42.0))),
"Conversations list metadata is not present"
);
}

@Test
void failsOnNonStringFieldValues() throws Exception {
webTestHelper.post("/metadata.upsert",
"{\"subject\": \"channel\", \"id\": \"" + channel.getId() + "\", \"data\": {\"sentFrom\": 123}}")
.andExpect(status().isBadRequest());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static co.airy.core.api.communication.util.Topics.applicationCommunicationMessages;
import static co.airy.core.api.communication.util.Topics.getTopics;
import static co.airy.test.Timing.retryOnException;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
Expand Down Expand Up @@ -75,7 +76,7 @@ void canResetUnreadCount() throws Exception {
kafkaTestHelper.produceRecord(new ProducerRecord<>(applicationCommunicationChannels.name(), channel.getId(), channel));

final String conversationId = UUID.randomUUID().toString();
final int unreadMessages = 3;
final Integer unreadMessages = 3;

kafkaTestHelper.produceRecords(TestConversation.generateRecords(conversationId, channel, unreadMessages));

Expand All @@ -98,15 +99,15 @@ void canResetUnreadCount() throws Exception {

retryOnException(() -> webTestHelper.post("/conversations.info", payload)
.andExpect(status().isOk())
.andExpect(jsonPath("$.metadata.unread_count", equalTo(unreadMessages))),
.andExpect(jsonPath("$.metadata.unread_count", is(3.0))),
"Conversation not showing unread count");

webTestHelper.post("/conversations.mark-read", payload).andExpect(status().isNoContent());

retryOnException(
() -> webTestHelper.post("/conversations.info", payload)
.andExpect(status().isOk())
.andExpect(jsonPath("$.metadata.unread_count", equalTo(0))),
.andExpect(jsonPath("$.metadata.unread_count", equalTo(0.0))),
"Conversation unread count did not reset");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public static class MetadataKeys {
public static String CONVERSATIONS = "conversations";
public static String METADATA = "metadata";
public static String MERGE_HISTORY = "mergeHistory";
public static String LANGUAGE = "language";

public static String ADDRESS = "address";

Expand Down
Loading

0 comments on commit 1a54507

Please sign in to comment.