WEBVTT

00:00.280 --> 00:02.240
So hi everyone.

00:02.240 --> 00:09.080
In this video I will show you how we can create one more method.

00:09.960 --> 00:20.640
Okay, for the app participants into the group chat okay into the conversation group.

00:21.760 --> 00:24.000
Okay, so let me show you how we can do that.

00:24.400 --> 00:27.360
Let's create the app okay.

00:27.360 --> 00:27.960
See one.

00:32.400 --> 00:35.520
Method over here okay.

00:36.240 --> 00:43.000
And now what we need firstly we need a the conversation ID right.

00:43.600 --> 00:48.320
We need a conversation ID and we need the current user.

00:55.040 --> 00:56.400
And we need the.

00:58.440 --> 01:03.050
ID we want to add, right?

01:20.050 --> 01:26.850
Right here, instead of moving directly over here, we can create the new.

01:32.290 --> 01:33.570
Than the data.

01:34.450 --> 01:35.850
Let me show you right here.

01:35.850 --> 01:39.210
I will create at least one.

01:46.130 --> 01:52.730
Of the S class are visible.

01:55.970 --> 01:56.610
Right here.

01:57.660 --> 01:58.100
Okay.

01:58.140 --> 01:58.620
Right here.

01:58.620 --> 02:01.700
We need to put the participant array over here.

02:02.940 --> 02:03.460
Right.

02:04.420 --> 02:07.380
And let's add a little bit of validation.

02:22.100 --> 02:22.620
Okay.

02:24.180 --> 02:29.420
And right here with the art practice ribbon.

02:44.380 --> 02:44.660
Okay.

02:44.780 --> 02:47.300
Firstly we need to find the conversation.

02:54.220 --> 02:55.260
What we have right now.

03:03.590 --> 03:06.230
Before anybody with the idea over here.

03:06.790 --> 03:08.190
And we need to check if.

03:10.310 --> 03:18.310
We're not part of the conversation or conversation is is not over.

03:19.190 --> 03:19.750
Okay.

03:21.310 --> 03:23.190
It will not follow conversation.

03:23.190 --> 03:29.910
Or if the conversation is, uh, is not a verb I will throw.

03:32.470 --> 03:35.030
Nail not file exception.

03:38.030 --> 03:38.510
Sorry.

03:52.710 --> 03:53.110
Okay.

03:53.150 --> 04:00.880
The reason In order to add a participant, we only allow add participants into the group chat.

04:00.920 --> 04:04.600
Okay, so if this is not a group, we will draw the arrow.

04:05.720 --> 04:11.160
And right here we need to add a little bit of code over here.

04:11.200 --> 04:14.320
Let me list just three.

04:16.760 --> 04:17.760
But this is what okay.

04:17.800 --> 04:22.480
This is the participant we want to to add right.

04:22.760 --> 04:24.760
We want to add into the group chat.

04:25.880 --> 04:26.480
So.

04:28.560 --> 04:29.560
What we need to do.

04:32.880 --> 04:34.320
Is add a conversation.

04:34.800 --> 04:39.000
We have a participants right.

04:39.520 --> 04:42.400
We have one right now.

04:46.800 --> 04:50.040
We can add that.

04:50.080 --> 05:02.890
We can put Booth does over here with the conversation part one and the new part one, and we need to

05:02.890 --> 05:04.610
remove the duplicate also.

05:05.970 --> 05:06.490
Okay.

05:07.970 --> 05:12.410
With this approach we have a little TypeScript problem.

05:13.090 --> 05:13.450
Um.

05:15.610 --> 05:23.330
Uh, so for that reason, let me, uh, try to fix us instead of this one.

05:24.290 --> 05:25.930
This is the ID, okay?

05:25.970 --> 05:35.250
This is the structuring of ID, so we need to somehow find the participant and convert it into the user

05:35.290 --> 05:37.330
document and put that over here.

05:39.810 --> 05:41.530
Right here will be participant.

05:46.930 --> 05:47.450
Okay.

05:48.090 --> 05:50.010
I will call this either a right.

05:50.010 --> 05:50.100
Anyway.

05:53.140 --> 05:57.740
And I will look through the participant array.

06:08.620 --> 06:11.140
Again and I will find the user.

06:12.020 --> 06:17.860
So in this case we need to inject the user service over here.

06:34.260 --> 06:37.660
And it does insert a module.

06:45.460 --> 06:47.780
After that let's go back.

06:53.950 --> 06:55.270
Use are equal.

06:56.630 --> 07:05.470
Please do not use a service dot file one with a participant array over here.

07:06.470 --> 07:07.030
Okay.

07:07.390 --> 07:08.190
With here.

07:10.390 --> 07:11.830
We have a user.

07:14.070 --> 07:14.630
Right.

07:16.390 --> 07:24.070
And right here we can put that into the one user over here.

07:27.630 --> 07:28.150
Okay.

07:30.510 --> 07:32.030
Right here we need to add.

07:34.630 --> 07:37.910
The user document.

07:39.150 --> 07:39.710
All right.

07:41.070 --> 07:41.710
Let us.

07:42.910 --> 07:44.510
And that is right.

07:45.150 --> 07:49.640
Right here let me uncomment And we will use the participant over here.

07:52.240 --> 07:55.880
And this already fixed the issue.

07:56.760 --> 07:57.920
And we need one more.

07:57.960 --> 07:58.720
One more thing.

07:59.760 --> 08:02.480
We need to remove the duplicate right.

08:02.480 --> 08:04.120
We need to remove duplicate.

08:04.440 --> 08:06.240
So how do we do that.

08:07.400 --> 08:07.960
So.

08:11.560 --> 08:17.240
With this approach it will duplicate for sure.

08:18.560 --> 08:22.120
For example with the conversation number 31.

08:24.160 --> 08:27.120
It can be a b and C.

08:27.560 --> 08:28.080
Okay.

08:28.800 --> 08:34.880
What about this participant over here is under C and d okay.

08:34.920 --> 08:45.090
It means it will somehow merge into this thing will be a, b, c and c and d Okay.

08:45.130 --> 08:45.610
Okay.

08:45.890 --> 08:48.650
This man right here will be duplicate for sure.

08:48.930 --> 08:49.410
Right.

08:49.890 --> 08:52.730
So we need to add a little bit of jack over here.

08:54.050 --> 08:58.650
Let me separate thing into the another variable.

08:59.330 --> 09:04.010
We will call the existing existing participant.

09:09.890 --> 09:10.530
Class.

09:11.410 --> 09:11.970
Okay.

09:13.290 --> 09:25.410
And in here we will check that if the existing participant dot include.

09:27.530 --> 09:28.010
The.

09:28.130 --> 09:32.730
But this one had a uh.

09:36.090 --> 09:42.930
Right here we will user whom we cannot compare to object.

09:43.300 --> 09:47.740
So for a reason with this guy, we need to map it into the object.

09:47.940 --> 09:56.180
Also, I will call this here will be practicing one practice 1.10.2.

09:57.540 --> 09:58.020
Okay.

09:58.580 --> 10:01.980
And I will call existing participants.

10:03.940 --> 10:05.900
It is something like that.

10:06.460 --> 10:14.780
And now here we need to check if exit participant ID is right here.

10:17.180 --> 10:18.060
In close.

10:18.660 --> 10:24.660
If it not close we will boost that into here.

10:25.820 --> 10:26.340
Okay.

10:26.860 --> 10:34.300
So with this approach it will for sure not duplicate because we already checked over here right.

10:35.660 --> 10:38.740
If the participant right here.

10:42.030 --> 10:50.750
Is already inside exiting a knot inside the exiting we will boost that.

10:51.430 --> 10:55.750
Okay so arrow here we have a current user.

10:55.750 --> 10:59.070
We need to check only the owner can.

11:01.790 --> 11:03.550
Add the participant okay.

11:31.590 --> 11:32.110
Okay.

11:32.950 --> 11:44.430
If the current user is not group owner we will route No problem, etc..

11:44.950 --> 11:45.790
Linus.

11:46.630 --> 11:48.070
Now let's try this.

11:59.790 --> 12:02.310
Okay, let me create a controller first.

12:12.630 --> 12:19.430
I will still use the match method and add the segments.

12:20.710 --> 12:23.550
Okay, now let's take a look at document.

12:24.630 --> 12:24.950
Uh.

12:25.070 --> 12:32.430
In order to add member to chat group, we will use conversation ID and class members.

12:32.470 --> 12:32.910
Right.

12:39.360 --> 12:40.400
Something like that.

12:42.560 --> 12:47.360
And we did the other day and released the update.

12:50.440 --> 12:54.040
Now we need that up a little.

13:07.640 --> 13:08.280
Over here.

13:10.600 --> 13:11.920
Let's save it as.

13:27.920 --> 13:30.000
We have an error over here.

13:32.120 --> 13:34.560
Let me change.

13:34.560 --> 13:37.050
The current user will be the last argument.

13:41.570 --> 13:43.570
So let's take that.

13:44.650 --> 13:45.530
Let me duplicate.

13:50.050 --> 13:56.370
And I will call up members to convert session.

13:58.250 --> 14:02.170
We did conversation today and we need are members.

14:06.130 --> 14:06.570
Okay.

14:06.570 --> 14:10.210
And right now we are in with the owner account.

14:20.490 --> 14:20.890
Here.

14:21.690 --> 14:23.930
And we need to add the participle.

14:33.850 --> 14:37.740
Now let's say what is here.

14:39.620 --> 14:43.380
Now let me file split ID inside MongoDB.

14:43.860 --> 14:44.740
So say.

14:48.980 --> 14:50.180
Conversations.

14:51.380 --> 14:55.260
This data here will be one, two, three.

14:58.900 --> 15:02.900
Here we already have a three partition one right.

15:03.340 --> 15:03.660
Right.

15:03.660 --> 15:08.900
Now if I add exactly the same to say it duplicate or not.

15:16.980 --> 15:17.540
Okay.

15:17.900 --> 15:19.820
Now let me say.

15:23.420 --> 15:26.380
Its value in this.

15:30.820 --> 15:33.030
Again I already a little bit raw.

15:33.870 --> 15:34.270
No.

15:36.350 --> 15:38.070
Let me generate a little bit.

15:38.710 --> 15:42.990
I already incorrect placement.

15:43.030 --> 15:44.630
It is okay.

15:44.910 --> 15:45.750
These are the service.

15:45.790 --> 15:46.790
Let's fix that.

15:48.270 --> 15:52.070
And right here let me fix that also.

16:04.590 --> 16:05.630
Now let me say.

16:08.030 --> 16:09.590
The message will be success.

16:09.630 --> 16:11.270
Now let's check the database.

16:21.630 --> 16:23.710
From here it not duplicate at all.

16:23.750 --> 16:24.230
Right.

16:24.710 --> 16:24.990
Right.

16:24.990 --> 16:30.630
Now if I remove the last one, we will a nine.

16:31.040 --> 16:32.480
Okay, let me move.

16:46.120 --> 16:49.040
Uh, we have some error.

16:49.080 --> 16:50.840
Let me, uh, refresh.

17:03.600 --> 17:05.000
Remove eight.

17:05.000 --> 17:05.320
Nine.

17:13.280 --> 17:13.680
Hmm.

17:14.440 --> 17:16.240
We have some error right now.

17:16.240 --> 17:17.160
I don't know why.

17:19.440 --> 17:20.120
Maybe.

17:21.080 --> 17:24.720
Maybe I will add into this group.

17:24.760 --> 17:27.680
Okay, I will add into this group.

17:31.970 --> 17:33.330
And I will add a member.

17:34.170 --> 17:34.570
Okay.

17:34.570 --> 17:40.770
Right now you can say we only have three members inside here, right?

17:40.970 --> 17:43.450
I will add with three member.

17:43.650 --> 17:53.690
Also, I expect it will add only one member because we already had a duplicate right now, right.

17:54.690 --> 18:06.490
Finite and zero f finite one here and zero f okay I want to add all these 43189 over here.

18:07.010 --> 18:07.530
Let's say.

18:09.930 --> 18:13.050
Inside the conversation of five.

18:15.130 --> 18:15.930
Billion.

18:18.730 --> 18:20.210
Conversation of five.

18:29.100 --> 18:29.660
Why?

18:45.500 --> 18:47.820
Are there isn't because.

18:50.020 --> 18:53.500
This is the AC waveform.

18:53.620 --> 18:54.060
Okay.

18:54.100 --> 18:55.860
We cannot do that.

18:56.060 --> 18:58.180
Let me try to remove this one.

19:01.220 --> 19:01.780
Okay.

19:05.820 --> 19:06.340
Okay.

19:06.780 --> 19:09.140
I can update this here.

19:09.540 --> 19:11.860
Let me copy and boost over here.

19:14.300 --> 19:14.940
Instead.

19:16.060 --> 19:16.700
Success.

19:17.460 --> 19:18.380
Let me refresh.

19:18.420 --> 19:22.380
I only will have a three in here.

19:30.350 --> 19:31.190
Roger is.

19:31.190 --> 19:32.070
Still are.

19:34.150 --> 19:35.550
You still here?

19:36.430 --> 19:36.790
Hmm.

19:37.910 --> 19:38.550
Let's see.

19:40.310 --> 19:41.950
Let me check a little bit.

19:45.910 --> 19:48.430
Let me try to console.log.

19:53.670 --> 19:55.150
Let me try to console.log.

20:05.830 --> 20:06.470
Say.

20:08.870 --> 20:10.590
We already have here.

20:11.830 --> 20:12.390
Right.

20:13.270 --> 20:15.950
And let me console.log the exiting.

20:19.030 --> 20:19.350
Okay.

20:19.350 --> 20:19.590
So.

20:30.200 --> 20:30.840
And we say.

20:33.640 --> 20:35.400
Okay, we have here.

20:37.080 --> 20:37.560
Here.

20:39.360 --> 20:40.480
It already worked.

20:40.520 --> 20:41.400
But why?

20:42.480 --> 20:44.280
Let me try to console.

20:46.960 --> 20:48.480
Up over here.

21:03.640 --> 21:04.000
Oh.

21:04.240 --> 21:05.040
Another reason.

21:05.080 --> 21:07.280
The reason I forgot to say.

21:07.560 --> 21:08.680
Into the database.

21:09.040 --> 21:09.560
Okay.

21:09.760 --> 21:11.280
Conversation side.

21:12.040 --> 21:12.560
Okay.

21:14.480 --> 21:15.120
My bad.

21:25.530 --> 21:26.570
Now let me say.

21:29.690 --> 21:31.090
And let's check the data wise.

21:46.050 --> 21:48.450
Here we already have a three.

21:48.490 --> 21:48.930
Okay.

21:49.010 --> 21:53.650
And even if I send one more time, it's still free.

22:01.850 --> 22:02.410
Okay.

22:02.570 --> 22:06.690
It means the logic right here already work.

22:07.170 --> 22:12.010
And we have so many mistake over here because.

22:14.290 --> 22:15.770
I want to sleep.

22:16.410 --> 22:17.970
So that is.

22:18.130 --> 22:21.650
I hope you understand this video and I will see you in.
