Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement user blocking/unblocking flow #5

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e3bc8c1
Define `UserChats` proto messages.
Vladyslav-Kuksiuk Mar 10, 2023
c681953
Implement `UserChatsAggregate` as user's part.
Vladyslav-Kuksiuk Mar 10, 2023
81ed94d
Implement `UserChatsRepository`.
Vladyslav-Kuksiuk Mar 10, 2023
ca62ed8
Add test on `UserChats` creation.
Vladyslav-Kuksiuk Mar 10, 2023
72619d3
Merge `user` and `userchats` into one package.
Vladyslav-Kuksiuk Mar 10, 2023
17b199d
Make `User` and `UserChats` different aggregates.
Vladyslav-Kuksiuk Mar 10, 2023
409900a
Implement `UserBlocklistProjection`.
Vladyslav-Kuksiuk Mar 10, 2023
f6626f1
Add test on `UserBlocklistProjection` creation.
Vladyslav-Kuksiuk Mar 10, 2023
fbabdc5
Add `package-info` for packages.
Vladyslav-Kuksiuk Mar 10, 2023
217f442
Make blocklist creation on the `UserChatsCreated` event.
Vladyslav-Kuksiuk Mar 10, 2023
10fdb80
Fix events and commands `package-info`s in `model` module.
Vladyslav-Kuksiuk Mar 12, 2023
cf53839
Remove redundant back-ticks in javadocs.
Vladyslav-Kuksiuk Mar 13, 2023
324be68
Merge `UserChats` into `User`.
Vladyslav-Kuksiuk Mar 13, 2023
545b10a
Define proto messages for user blocking flow.
Vladyslav-Kuksiuk Mar 13, 2023
d08157d
Implement user blocking flow.
Vladyslav-Kuksiuk Mar 13, 2023
e2b7b9c
Add a positive test on user blocking.
Vladyslav-Kuksiuk Mar 13, 2023
5f94c4b
Update `UserBlocklistProjectionTest`.
Vladyslav-Kuksiuk Mar 13, 2023
33a8973
Implement blocking rejection.
Vladyslav-Kuksiuk Mar 13, 2023
53f8fb3
Add a test for rejection to block a user.
Vladyslav-Kuksiuk Mar 14, 2023
e43bf3a
Define proto messages for user unblocking.
Vladyslav-Kuksiuk Mar 14, 2023
2b22040
Implement user unblocking flow.
Vladyslav-Kuksiuk Mar 14, 2023
25c7da6
Fix naming in `repeated` fields in proto messages.
Vladyslav-Kuksiuk Mar 14, 2023
f712529
Add tests on user unblocking flow.
Vladyslav-Kuksiuk Mar 14, 2023
683d405
Update copyright in `rejections.proto`.
Vladyslav-Kuksiuk Mar 14, 2023
382d9d0
Fix `blocked_user` field name in `user_blocklist.proto`.
Vladyslav-Kuksiuk Mar 14, 2023
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
38 changes: 38 additions & 0 deletions model/src/main/java/io/spine/examples/chatspn/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2023, TeamDev. All rights reserved.
*
* 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
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/**
* This package contains basic data types of the ChatSPN application.
*/
@BoundedContext("Chats")
@CheckReturnValue
@ParametersAreNonnullByDefault
package io.spine.examples.chatspn;

import com.google.errorprone.annotations.CheckReturnValue;
import io.spine.core.BoundedContext;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2023, TeamDev. All rights reserved.
*
* 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
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/**
* Provides ChatSPN User commands and common commands interfaces.
*/
@CheckReturnValue
@ParametersAreNonnullByDefault
package io.spine.examples.chatspn.user.command;

import com.google.errorprone.annotations.CheckReturnValue;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2023, TeamDev. All rights reserved.
*
* 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
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/**
* Provides ChatSPN User events and common event interfaces.
*/
@CheckReturnValue
@ParametersAreNonnullByDefault
package io.spine.examples.chatspn.user.event;

import com.google.errorprone.annotations.CheckReturnValue;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2023, TeamDev. All rights reserved.
*
* 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
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/**
* This package contains User data types of the ChatSPN application.
*/
@CheckReturnValue
@ParametersAreNonnullByDefault
package io.spine.examples.chatspn.user;

import com.google.errorprone.annotations.CheckReturnValue;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2023, TeamDev. All rights reserved.
*
* 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
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/**
* Provides ChatSPN User rejections.
*/
@CheckReturnValue
@ParametersAreNonnullByDefault
package io.spine.examples.chatspn.user.rejection;

import com.google.errorprone.annotations.CheckReturnValue;

import javax.annotation.ParametersAreNonnullByDefault;
40 changes: 40 additions & 0 deletions model/src/main/proto/spine_examples/chatspn/identifiers.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2023, TeamDev. All rights reserved.
*
* 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
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
syntax = "proto3";

package spine_examples.chatspn;

import "spine/options.proto";

option (type_url_prefix) = "type.chatspn.spine.io";
option java_package = "io.spine.examples.chatspn";
option java_outer_classname = "IdentifiersProto";
option java_multiple_files = true;

// Identifies a chat in the scope of the application.
message ChatId {
string uuid = 1 [(required) = true];
}
20 changes: 20 additions & 0 deletions model/src/main/proto/spine_examples/chatspn/user/commands.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,23 @@ message RegisterUser {
// A name of the user to register.
string name = 2 [(required) = true];
}

// Tells to block user.
message BlockUser {

// The ID of the user who wants to block.
spine.core.UserId user_who_block = 1;

// The ID of the user to be blocked.
spine.core.UserId user_to_block = 2 [(required) = true];
}

// Tells to unblock user.
message UnblockUser {

// The ID of the user who wants to unblock.
spine.core.UserId user_who_unblock = 1;

// The ID of the user to be unblocked.
spine.core.UserId user_to_unblock = 2 [(required) = true];
}
20 changes: 20 additions & 0 deletions model/src/main/proto/spine_examples/chatspn/user/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,23 @@ message UserRegistered {
// A name of the registered user.
string name = 2 [(required) = true];
}

// A user has been blocked.
message UserBlocked {

// The ID of the user who blocked.
spine.core.UserId blocking_user = 1;

// The ID of the user who was blocked.
spine.core.UserId blocked_user = 2 [(required) = true];
}

// A user has been unblocked.
message UserUnblocked {

// The ID of the user who unblocked.
spine.core.UserId unblocking_user = 1;

// The ID of the user who was unblocked.
spine.core.UserId unblocked_user = 2 [(required) = true];
}
64 changes: 64 additions & 0 deletions model/src/main/proto/spine_examples/chatspn/user/rejections.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2023, TeamDev. All rights reserved.
*
* 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
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
syntax = "proto3";

package spine_examples.chatspn.user;

import "spine/options.proto";

option (type_url_prefix) = "type.chatspn.spine.io";
option java_package = "io.spine.examples.chatspn.user.rejection";

// Set the value of `java_multiple_files` to `false` to instruct Protobuf Compiler to put all the
// rejection classes in one outer class.
//
// Then Spine Model Compiler for Java would generate `ThrowableMessage` classes for all
// these messages. These classes will be named after the classes of rejection messages.
// Putting rejection message classes under an outer class avoids name clash inside the package.
//
option java_multiple_files = false;

import "spine/core/user_id.proto";

// A user cannot be blocked.
message UserCannotBeBlocked {

// The ID of the user that could not block.
spine.core.UserId user_who_block = 1;

// The ID of the user that could not be blocked.
spine.core.UserId user_to_block = 2 [(required) = true];
}

// A user cannot be unblocked.
message UserCannotBeUnblocked {

// The ID of the user that could not unblock.
spine.core.UserId user_who_unblock = 1;

// The ID of the user that could not be unblocked.
spine.core.UserId user_to_unblock = 2 [(required) = true];
}
10 changes: 10 additions & 0 deletions model/src/main/proto/spine_examples/chatspn/user/user.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ option java_multiple_files = true;

import "google/protobuf/timestamp.proto";
import "spine/core/user_id.proto";
import "spine_examples/chatspn/identifiers.proto";

// A user in the chatting system.
message User {
Expand All @@ -52,4 +53,13 @@ message User {

// A time of last user activity.
google.protobuf.Timestamp when_last_active = 3;

// The chats in which the user is a member.
repeated ChatId chat = 4;

// The chats that the user has muted.
repeated ChatId muted_chat = 5;

// The users that the user has blocked.
repeated spine.core.UserId blocked_user = 6;
}
Loading