WEBVTT

00:00.840 --> 00:02.320
Hey everyone!

00:03.280 --> 00:11.080
In previous video, we already created a private conversation for 1 to 1 chats.

00:11.360 --> 00:19.560
Okay, in this video, let's create another method for creating group conversation.

00:20.400 --> 00:22.960
Okay, so let's build us.

00:24.240 --> 00:27.640
We need here a current user.

00:33.120 --> 00:34.880
And let's see how we can build us.

00:35.160 --> 00:36.480
If you take a look.

00:38.880 --> 00:42.920
If you take a look at this create private.

00:43.520 --> 00:46.760
We need to check the existing conversation.

00:47.440 --> 00:50.960
And if we already have an existing we will return that.

00:51.400 --> 00:53.680
So how about create group.

00:54.400 --> 01:02.190
Well in the group create group conversation We don't need any object over here.

01:02.870 --> 01:03.990
Let me show you why.

01:04.830 --> 01:06.470
Well, the reason is very simple.

01:07.990 --> 01:14.950
We will allow the user can create multiple groups with same frames.

01:15.550 --> 01:17.590
Okay, let me show you what I mean.

01:17.630 --> 01:23.510
Furthermore, it later we can have a multiple group for example like food group.

01:23.750 --> 01:24.110
Okay.

01:24.150 --> 01:32.590
If the food group we have A, B and C and in later we can create a relaxed group.

01:33.710 --> 01:39.510
We will also have a, B and C and this will be completely normal okay.

01:39.550 --> 01:42.790
We can allow the user can create that right.

01:43.070 --> 01:46.230
So for that reason we don't need to check in here.

01:47.470 --> 01:56.230
The existing conversation only work for chart with the one frame okay.

01:56.670 --> 01:59.830
What is that a totally different story.

02:00.390 --> 02:03.910
So for a reason we don't need to check anything over here.

02:04.590 --> 02:10.270
Now let's continue with a little.

02:10.990 --> 02:18.350
Let me check create group conversation video and let me go back over here.

02:18.790 --> 02:19.590
Change the name.

02:23.750 --> 02:24.950
And chain over here.

02:28.750 --> 02:29.270
Okay.

02:29.790 --> 02:31.470
What you saw a little.

02:31.590 --> 02:32.670
Let me show you.

02:34.270 --> 02:39.110
On a ski mask, you can say firstly, we did this once, right?

02:41.630 --> 02:45.230
Right here we did participant IDs of the sprint.

02:45.230 --> 02:46.790
Right over here.

02:52.910 --> 02:53.430
Okay.

02:56.380 --> 02:57.380
And, uh.

02:59.700 --> 03:01.580
Let me show you what it means.

03:03.860 --> 03:06.460
It creates private conversation.

03:06.460 --> 03:10.300
We only put the one participant at a time.

03:10.420 --> 03:10.940
Reason?

03:10.940 --> 03:13.780
Because this is a 1 to 1 chat.

03:13.820 --> 03:14.180
Okay.

03:14.220 --> 03:16.820
We only chat with one frame at a time.

03:17.100 --> 03:19.740
So we only need one participant.

03:20.300 --> 03:25.820
But with the group, we need to boost the real participants, right?

03:25.820 --> 03:32.820
Because we can create the group with multiple members inside us, right?

03:33.940 --> 03:35.420
Let me show you how it works.

03:43.540 --> 03:44.460
And right here.

03:47.220 --> 03:53.180
And right here let's chat a little bit about arrays and the array over here.

03:53.500 --> 03:53.860
Okay.

03:53.860 --> 03:55.010
And It might be in future.

03:55.010 --> 03:56.930
We can boost so many.

03:56.970 --> 03:57.490
All right.

03:57.530 --> 03:58.250
Right here.

03:58.290 --> 03:59.050
If you want.

04:00.050 --> 04:03.010
We need to add a little bit of validations.

04:03.650 --> 04:05.610
So this is the right.

04:06.010 --> 04:06.530
Right.

04:07.850 --> 04:10.010
And uh we need to make sure.

04:11.610 --> 04:17.370
And the element inside the string array here should be a MongoDB object.

04:22.130 --> 04:27.370
And we call this array we cannot check like that okay.

04:27.650 --> 04:30.850
We cannot do directly the mongo ID.

04:31.250 --> 04:34.130
This only work with this is the normal string.

04:34.930 --> 04:43.850
But since this is the uh right we can boost the option which we will choose.

04:44.210 --> 04:44.690
Okay.

04:45.850 --> 04:54.400
We feel it will look through the element inside the array over here and jack with every element.

04:55.160 --> 04:59.600
It will make sure this is the mongo ID, so very good.

05:00.440 --> 05:03.400
And let me show you this.

05:03.400 --> 05:04.480
Here we run this.

05:06.280 --> 05:07.240
We run this here.

05:07.240 --> 05:10.040
So we need the avatar and group name.

05:16.320 --> 05:19.880
So for that reason go back to the DTO and move that over here.

05:21.240 --> 05:23.720
The avatar can be either media.

05:24.120 --> 05:27.880
Hi sorry we are tile over here.

05:29.000 --> 05:33.400
And group name will be straight okay.

05:33.600 --> 05:36.120
With the avatar this can be optional.

05:36.880 --> 05:37.400
Sorry.

05:38.560 --> 05:46.080
The optional and width is group name I will add is not contained.

05:46.760 --> 05:51.670
Okay, maybe you don't want to put the group name.

05:52.270 --> 05:52.710
Okay.

05:52.750 --> 06:04.030
You can use the the file or something like that, but I did replace I will create the group name when

06:04.030 --> 06:06.670
we create the group chart.

06:06.710 --> 06:07.150
Okay.

06:08.550 --> 06:13.270
So after that uh, let's try it.

06:14.510 --> 06:18.910
Let me copy this lab code and put that inside a group.

06:20.230 --> 06:20.790
Right here.

06:20.790 --> 06:22.310
Let me destructuring.

06:30.870 --> 06:31.390
Okay.

06:31.550 --> 06:33.950
So here let me add this.

06:34.590 --> 06:36.950
And because this is the array.

06:36.990 --> 06:42.750
So we need to, uh, use the separate operator over here.

06:44.350 --> 06:46.950
And after that is here should be true.

06:47.230 --> 06:47.710
Right.

06:48.150 --> 06:53.870
And we have a group name and group avatar and group owner.

06:54.110 --> 06:55.590
What is the group owner?

06:56.190 --> 06:59.230
Group owner should be the current user, right?

07:00.550 --> 07:01.470
And over here.

07:06.790 --> 07:10.510
So I hope you understand this logic.

07:13.630 --> 07:19.430
Now let me go to the controllers and I will remove the boss method over here.

07:20.030 --> 07:21.670
Let me duplicate this.

07:26.150 --> 07:26.710
Group.

07:50.980 --> 07:52.460
Now let's change the method.

07:57.020 --> 07:57.500
Okay.

07:58.140 --> 07:58.780
Like this.

07:59.020 --> 08:02.900
And let's remove the news import over here.

08:03.700 --> 08:05.380
And we have the error.

08:06.780 --> 08:09.660
Uh, come from here.

08:09.700 --> 08:10.500
Let me click.

08:12.260 --> 08:17.180
Um, well, it's a lot of ground up that little.

08:17.620 --> 08:19.260
Let me remove the stain.

08:22.100 --> 08:22.820
Remove here.

08:24.780 --> 08:25.300
Okay.

08:27.620 --> 08:29.460
And, uh, let's say.

08:33.580 --> 08:37.620
We have the error come from the service.

08:38.300 --> 08:38.780
Okay.

08:38.820 --> 08:40.620
Let's remove the news import.

08:46.770 --> 08:47.570
And let's say.

08:51.090 --> 08:53.690
Right now, the application already successfully.

08:55.410 --> 09:04.050
Let me go to here and I will go to the users and copy one more participant.

09:04.050 --> 09:07.290
It is the Thomas Adi.

09:09.330 --> 09:10.570
Buddha design here.

09:11.970 --> 09:13.810
And the group name.

09:15.850 --> 09:16.770
Can be.

09:19.050 --> 09:23.650
For example, I put zero.

09:24.410 --> 09:28.050
For example, let us and let's say we have.

09:31.210 --> 09:31.650
Okay.

09:31.650 --> 09:33.850
We only need this one.

09:33.850 --> 09:35.610
We don't need the avatar right now.

09:36.730 --> 09:39.770
Let me say okay.

09:39.930 --> 09:40.650
Very good.

09:40.690 --> 09:45.450
We already created our group and this already have a participant.

09:45.490 --> 09:49.010
This is the current user already logged in.

09:49.690 --> 09:50.210
Okay.

09:50.770 --> 09:54.050
And also this one.

09:54.410 --> 09:54.890
Right.

09:55.490 --> 09:58.410
And we already have our own participants.

09:59.490 --> 10:00.570
Very very cool.

10:01.610 --> 10:07.170
And let me create one more group with the group avatar.

10:08.930 --> 10:14.490
So let me show you how it works in the group avatar result object.

10:14.530 --> 10:15.010
Right.

10:15.690 --> 10:18.530
Let me create a crowded array.

10:18.970 --> 10:20.770
Let me try to upload the file.

10:24.250 --> 10:25.930
Let me show some file.

10:28.050 --> 10:28.650
Say.

10:32.970 --> 10:33.330
And.

10:35.930 --> 10:36.850
Go down over here.

10:41.840 --> 10:50.840
Okay, let me try to set that with the, uh, food group.

10:51.480 --> 10:56.240
I will create a resource group with the same participant.

10:56.600 --> 10:58.520
Let me say, okay.

10:58.560 --> 11:01.440
We already got the group avatar.

11:02.160 --> 11:03.520
Let me check the database.

11:17.960 --> 11:20.560
Now, we already got the new one.

11:21.000 --> 11:25.680
Food group and resource group with the avatar over here.

11:26.560 --> 11:31.480
Okay, so that's for the video.

11:31.760 --> 11:34.000
I hope you understand the logic right here.

11:34.640 --> 11:38.480
It doesn't complicated at all, right?

11:39.800 --> 11:41.160
So I will see you in the.
