Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into feature/digest...
[akkoma] / test / web / twitter_api / twitter_api_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
6 use Pleroma.DataCase
7 alias Pleroma.Activity
8 alias Pleroma.Object
9 alias Pleroma.Repo
10 alias Pleroma.User
11 alias Pleroma.UserInviteToken
12 alias Pleroma.Web.ActivityPub.ActivityPub
13 alias Pleroma.Web.TwitterAPI.ActivityView
14 alias Pleroma.Web.TwitterAPI.TwitterAPI
15 alias Pleroma.Web.TwitterAPI.UserView
16
17 import Pleroma.Factory
18
19 setup_all do
20 Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
21 :ok
22 end
23
24 test "create a status" do
25 user = insert(:user)
26 mentioned_user = insert(:user, %{nickname: "shp", ap_id: "shp"})
27
28 object_data = %{
29 "type" => "Image",
30 "url" => [
31 %{
32 "type" => "Link",
33 "mediaType" => "image/jpg",
34 "href" => "http://example.org/image.jpg"
35 }
36 ],
37 "uuid" => 1
38 }
39
40 object = Repo.insert!(%Object{data: object_data})
41
42 input = %{
43 "status" =>
44 "Hello again, @shp.<script></script>\nThis is on another :moominmamma: line. #2hu #epic #phantasmagoric",
45 "media_ids" => [object.id]
46 }
47
48 {:ok, activity = %Activity{}} = TwitterAPI.create_status(user, input)
49
50 expected_text =
51 "Hello again, <span class='h-card'><a data-user='#{mentioned_user.id}' class='u-url mention' href='shp'>@<span>shp</span></a></span>.&lt;script&gt;&lt;/script&gt;<br>This is on another :moominmamma: line. <a class='hashtag' data-tag='2hu' href='http://localhost:4001/tag/2hu' rel='tag'>#2hu</a> <a class='hashtag' data-tag='epic' href='http://localhost:4001/tag/epic' rel='tag'>#epic</a> <a class='hashtag' data-tag='phantasmagoric' href='http://localhost:4001/tag/phantasmagoric' rel='tag'>#phantasmagoric</a><br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
52
53 assert get_in(activity.data, ["object", "content"]) == expected_text
54 assert get_in(activity.data, ["object", "type"]) == "Note"
55 assert get_in(activity.data, ["object", "actor"]) == user.ap_id
56 assert get_in(activity.data, ["actor"]) == user.ap_id
57 assert Enum.member?(get_in(activity.data, ["cc"]), User.ap_followers(user))
58
59 assert Enum.member?(
60 get_in(activity.data, ["to"]),
61 "https://www.w3.org/ns/activitystreams#Public"
62 )
63
64 assert Enum.member?(get_in(activity.data, ["to"]), "shp")
65 assert activity.local == true
66
67 assert %{"moominmamma" => "http://localhost:4001/finmoji/128px/moominmamma-128.png"} =
68 activity.data["object"]["emoji"]
69
70 # hashtags
71 assert activity.data["object"]["tag"] == ["2hu", "epic", "phantasmagoric"]
72
73 # Add a context
74 assert is_binary(get_in(activity.data, ["context"]))
75 assert is_binary(get_in(activity.data, ["object", "context"]))
76
77 assert is_list(activity.data["object"]["attachment"])
78
79 assert activity.data["object"] == Object.get_by_ap_id(activity.data["object"]["id"]).data
80
81 user = User.get_by_ap_id(user.ap_id)
82
83 assert user.info.note_count == 1
84 end
85
86 test "create a status that is a reply" do
87 user = insert(:user)
88
89 input = %{
90 "status" => "Hello again."
91 }
92
93 {:ok, activity = %Activity{}} = TwitterAPI.create_status(user, input)
94
95 input = %{
96 "status" => "Here's your (you).",
97 "in_reply_to_status_id" => activity.id
98 }
99
100 {:ok, reply = %Activity{}} = TwitterAPI.create_status(user, input)
101
102 assert get_in(reply.data, ["context"]) == get_in(activity.data, ["context"])
103
104 assert get_in(reply.data, ["object", "context"]) ==
105 get_in(activity.data, ["object", "context"])
106
107 assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
108 assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id
109 end
110
111 test "Follow another user using user_id" do
112 user = insert(:user)
113 followed = insert(:user)
114
115 {:ok, user, followed, _activity} = TwitterAPI.follow(user, %{"user_id" => followed.id})
116 assert User.ap_followers(followed) in user.following
117
118 {:error, msg} = TwitterAPI.follow(user, %{"user_id" => followed.id})
119 assert msg == "Could not follow user: #{followed.nickname} is already on your list."
120 end
121
122 test "Follow another user using screen_name" do
123 user = insert(:user)
124 followed = insert(:user)
125
126 {:ok, user, followed, _activity} =
127 TwitterAPI.follow(user, %{"screen_name" => followed.nickname})
128
129 assert User.ap_followers(followed) in user.following
130
131 followed = User.get_by_ap_id(followed.ap_id)
132 assert followed.info.follower_count == 1
133
134 {:error, msg} = TwitterAPI.follow(user, %{"screen_name" => followed.nickname})
135 assert msg == "Could not follow user: #{followed.nickname} is already on your list."
136 end
137
138 test "Unfollow another user using user_id" do
139 unfollowed = insert(:user)
140 user = insert(:user, %{following: [User.ap_followers(unfollowed)]})
141 ActivityPub.follow(user, unfollowed)
142
143 {:ok, user, unfollowed} = TwitterAPI.unfollow(user, %{"user_id" => unfollowed.id})
144 assert user.following == []
145
146 {:error, msg} = TwitterAPI.unfollow(user, %{"user_id" => unfollowed.id})
147 assert msg == "Not subscribed!"
148 end
149
150 test "Unfollow another user using screen_name" do
151 unfollowed = insert(:user)
152 user = insert(:user, %{following: [User.ap_followers(unfollowed)]})
153
154 ActivityPub.follow(user, unfollowed)
155
156 {:ok, user, unfollowed} = TwitterAPI.unfollow(user, %{"screen_name" => unfollowed.nickname})
157 assert user.following == []
158
159 {:error, msg} = TwitterAPI.unfollow(user, %{"screen_name" => unfollowed.nickname})
160 assert msg == "Not subscribed!"
161 end
162
163 test "Block another user using user_id" do
164 user = insert(:user)
165 blocked = insert(:user)
166
167 {:ok, user, blocked} = TwitterAPI.block(user, %{"user_id" => blocked.id})
168 assert User.blocks?(user, blocked)
169 end
170
171 test "Block another user using screen_name" do
172 user = insert(:user)
173 blocked = insert(:user)
174
175 {:ok, user, blocked} = TwitterAPI.block(user, %{"screen_name" => blocked.nickname})
176 assert User.blocks?(user, blocked)
177 end
178
179 test "Unblock another user using user_id" do
180 unblocked = insert(:user)
181 user = insert(:user)
182 {:ok, user, _unblocked} = TwitterAPI.block(user, %{"user_id" => unblocked.id})
183
184 {:ok, user, _unblocked} = TwitterAPI.unblock(user, %{"user_id" => unblocked.id})
185 assert user.info.blocks == []
186 end
187
188 test "Unblock another user using screen_name" do
189 unblocked = insert(:user)
190 user = insert(:user)
191 {:ok, user, _unblocked} = TwitterAPI.block(user, %{"screen_name" => unblocked.nickname})
192
193 {:ok, user, _unblocked} = TwitterAPI.unblock(user, %{"screen_name" => unblocked.nickname})
194 assert user.info.blocks == []
195 end
196
197 test "upload a file" do
198 user = insert(:user)
199
200 file = %Plug.Upload{
201 content_type: "image/jpg",
202 path: Path.absname("test/fixtures/image.jpg"),
203 filename: "an_image.jpg"
204 }
205
206 response = TwitterAPI.upload(file, user)
207
208 assert is_binary(response)
209 end
210
211 test "it favorites a status, returns the updated activity" do
212 user = insert(:user)
213 other_user = insert(:user)
214 note_activity = insert(:note_activity)
215
216 {:ok, status} = TwitterAPI.fav(user, note_activity.id)
217 updated_activity = Activity.get_by_ap_id(note_activity.data["id"])
218 assert ActivityView.render("activity.json", %{activity: updated_activity})["fave_num"] == 1
219
220 object = Object.normalize(note_activity.data["object"])
221
222 assert object.data["like_count"] == 1
223
224 assert status == updated_activity
225
226 {:ok, _status} = TwitterAPI.fav(other_user, note_activity.id)
227
228 object = Object.normalize(note_activity.data["object"])
229
230 assert object.data["like_count"] == 2
231
232 updated_activity = Activity.get_by_ap_id(note_activity.data["id"])
233 assert ActivityView.render("activity.json", %{activity: updated_activity})["fave_num"] == 2
234 end
235
236 test "it unfavorites a status, returns the updated activity" do
237 user = insert(:user)
238 note_activity = insert(:note_activity)
239 object = Object.get_by_ap_id(note_activity.data["object"]["id"])
240
241 {:ok, _like_activity, _object} = ActivityPub.like(user, object)
242 updated_activity = Activity.get_by_ap_id(note_activity.data["id"])
243
244 assert ActivityView.render("activity.json", activity: updated_activity)["fave_num"] == 1
245
246 {:ok, activity} = TwitterAPI.unfav(user, note_activity.id)
247
248 assert ActivityView.render("activity.json", activity: activity)["fave_num"] == 0
249 end
250
251 test "it retweets a status and returns the retweet" do
252 user = insert(:user)
253 note_activity = insert(:note_activity)
254
255 {:ok, status} = TwitterAPI.repeat(user, note_activity.id)
256 updated_activity = Activity.get_by_ap_id(note_activity.data["id"])
257
258 assert status == updated_activity
259 end
260
261 test "it unretweets an already retweeted status" do
262 user = insert(:user)
263 note_activity = insert(:note_activity)
264
265 {:ok, _status} = TwitterAPI.repeat(user, note_activity.id)
266 {:ok, status} = TwitterAPI.unrepeat(user, note_activity.id)
267 updated_activity = Activity.get_by_ap_id(note_activity.data["id"])
268
269 assert status == updated_activity
270 end
271
272 test "it registers a new user and returns the user." do
273 data = %{
274 "nickname" => "lain",
275 "email" => "lain@wired.jp",
276 "fullname" => "lain iwakura",
277 "password" => "bear",
278 "confirm" => "bear"
279 }
280
281 {:ok, user} = TwitterAPI.register_user(data)
282
283 fetched_user = User.get_by_nickname("lain")
284
285 assert UserView.render("show.json", %{user: user}) ==
286 UserView.render("show.json", %{user: fetched_user})
287 end
288
289 test "it registers a new user with empty string in bio and returns the user." do
290 data = %{
291 "nickname" => "lain",
292 "email" => "lain@wired.jp",
293 "fullname" => "lain iwakura",
294 "bio" => "",
295 "password" => "bear",
296 "confirm" => "bear"
297 }
298
299 {:ok, user} = TwitterAPI.register_user(data)
300
301 fetched_user = User.get_by_nickname("lain")
302
303 assert UserView.render("show.json", %{user: user}) ==
304 UserView.render("show.json", %{user: fetched_user})
305 end
306
307 test "it sends confirmation email if :account_activation_required is specified in instance config" do
308 setting = Pleroma.Config.get([:instance, :account_activation_required])
309
310 unless setting do
311 Pleroma.Config.put([:instance, :account_activation_required], true)
312 on_exit(fn -> Pleroma.Config.put([:instance, :account_activation_required], setting) end)
313 end
314
315 data = %{
316 "nickname" => "lain",
317 "email" => "lain@wired.jp",
318 "fullname" => "lain iwakura",
319 "bio" => "",
320 "password" => "bear",
321 "confirm" => "bear"
322 }
323
324 {:ok, user} = TwitterAPI.register_user(data)
325
326 assert user.info.confirmation_pending
327
328 Swoosh.TestAssertions.assert_email_sent(
329 Pleroma.Emails.UserEmail.account_confirmation_email(user)
330 )
331 end
332
333 test "it registers a new user and parses mentions in the bio" do
334 data1 = %{
335 "nickname" => "john",
336 "email" => "john@gmail.com",
337 "fullname" => "John Doe",
338 "bio" => "test",
339 "password" => "bear",
340 "confirm" => "bear"
341 }
342
343 {:ok, user1} = TwitterAPI.register_user(data1)
344
345 data2 = %{
346 "nickname" => "lain",
347 "email" => "lain@wired.jp",
348 "fullname" => "lain iwakura",
349 "bio" => "@john test",
350 "password" => "bear",
351 "confirm" => "bear"
352 }
353
354 {:ok, user2} = TwitterAPI.register_user(data2)
355
356 expected_text =
357 "<span class='h-card'><a data-user='#{user1.id}' class='u-url mention' href='#{user1.ap_id}'>@<span>john</span></a></span> test"
358
359 assert user2.bio == expected_text
360 end
361
362 describe "register with one time token" do
363 setup do
364 setting = Pleroma.Config.get([:instance, :registrations_open])
365
366 if setting do
367 Pleroma.Config.put([:instance, :registrations_open], false)
368 on_exit(fn -> Pleroma.Config.put([:instance, :registrations_open], setting) end)
369 end
370
371 :ok
372 end
373
374 test "returns user on success" do
375 {:ok, invite} = UserInviteToken.create_invite()
376
377 data = %{
378 "nickname" => "vinny",
379 "email" => "pasta@pizza.vs",
380 "fullname" => "Vinny Vinesauce",
381 "bio" => "streamer",
382 "password" => "hiptofbees",
383 "confirm" => "hiptofbees",
384 "token" => invite.token
385 }
386
387 {:ok, user} = TwitterAPI.register_user(data)
388
389 fetched_user = User.get_by_nickname("vinny")
390 invite = Repo.get_by(UserInviteToken, token: invite.token)
391
392 assert invite.used == true
393
394 assert UserView.render("show.json", %{user: user}) ==
395 UserView.render("show.json", %{user: fetched_user})
396 end
397
398 test "returns error on invalid token" do
399 data = %{
400 "nickname" => "GrimReaper",
401 "email" => "death@reapers.afterlife",
402 "fullname" => "Reaper Grim",
403 "bio" => "Your time has come",
404 "password" => "scythe",
405 "confirm" => "scythe",
406 "token" => "DudeLetMeInImAFairy"
407 }
408
409 {:error, msg} = TwitterAPI.register_user(data)
410
411 assert msg == "Invalid token"
412 refute User.get_by_nickname("GrimReaper")
413 end
414
415 test "returns error on expired token" do
416 {:ok, invite} = UserInviteToken.create_invite()
417 UserInviteToken.update_invite!(invite, used: true)
418
419 data = %{
420 "nickname" => "GrimReaper",
421 "email" => "death@reapers.afterlife",
422 "fullname" => "Reaper Grim",
423 "bio" => "Your time has come",
424 "password" => "scythe",
425 "confirm" => "scythe",
426 "token" => invite.token
427 }
428
429 {:error, msg} = TwitterAPI.register_user(data)
430
431 assert msg == "Expired token"
432 refute User.get_by_nickname("GrimReaper")
433 end
434 end
435
436 describe "registers with date limited token" do
437 setup do
438 setting = Pleroma.Config.get([:instance, :registrations_open])
439
440 if setting do
441 Pleroma.Config.put([:instance, :registrations_open], false)
442 on_exit(fn -> Pleroma.Config.put([:instance, :registrations_open], setting) end)
443 end
444
445 data = %{
446 "nickname" => "vinny",
447 "email" => "pasta@pizza.vs",
448 "fullname" => "Vinny Vinesauce",
449 "bio" => "streamer",
450 "password" => "hiptofbees",
451 "confirm" => "hiptofbees"
452 }
453
454 check_fn = fn invite ->
455 data = Map.put(data, "token", invite.token)
456 {:ok, user} = TwitterAPI.register_user(data)
457 fetched_user = User.get_by_nickname("vinny")
458
459 assert UserView.render("show.json", %{user: user}) ==
460 UserView.render("show.json", %{user: fetched_user})
461 end
462
463 {:ok, data: data, check_fn: check_fn}
464 end
465
466 test "returns user on success", %{check_fn: check_fn} do
467 {:ok, invite} = UserInviteToken.create_invite(%{expires_at: Date.utc_today()})
468
469 check_fn.(invite)
470
471 invite = Repo.get_by(UserInviteToken, token: invite.token)
472
473 refute invite.used
474 end
475
476 test "returns user on token which expired tomorrow", %{check_fn: check_fn} do
477 {:ok, invite} = UserInviteToken.create_invite(%{expires_at: Date.add(Date.utc_today(), 1)})
478
479 check_fn.(invite)
480
481 invite = Repo.get_by(UserInviteToken, token: invite.token)
482
483 refute invite.used
484 end
485
486 test "returns an error on overdue date", %{data: data} do
487 {:ok, invite} = UserInviteToken.create_invite(%{expires_at: Date.add(Date.utc_today(), -1)})
488
489 data = Map.put(data, "token", invite.token)
490
491 {:error, msg} = TwitterAPI.register_user(data)
492
493 assert msg == "Expired token"
494 refute User.get_by_nickname("vinny")
495 invite = Repo.get_by(UserInviteToken, token: invite.token)
496
497 refute invite.used
498 end
499 end
500
501 describe "registers with reusable token" do
502 setup do
503 setting = Pleroma.Config.get([:instance, :registrations_open])
504
505 if setting do
506 Pleroma.Config.put([:instance, :registrations_open], false)
507 on_exit(fn -> Pleroma.Config.put([:instance, :registrations_open], setting) end)
508 end
509
510 :ok
511 end
512
513 test "returns user on success, after him registration fails" do
514 {:ok, invite} = UserInviteToken.create_invite(%{max_use: 100})
515
516 UserInviteToken.update_invite!(invite, uses: 99)
517
518 data = %{
519 "nickname" => "vinny",
520 "email" => "pasta@pizza.vs",
521 "fullname" => "Vinny Vinesauce",
522 "bio" => "streamer",
523 "password" => "hiptofbees",
524 "confirm" => "hiptofbees",
525 "token" => invite.token
526 }
527
528 {:ok, user} = TwitterAPI.register_user(data)
529 fetched_user = User.get_by_nickname("vinny")
530 invite = Repo.get_by(UserInviteToken, token: invite.token)
531
532 assert invite.used == true
533
534 assert UserView.render("show.json", %{user: user}) ==
535 UserView.render("show.json", %{user: fetched_user})
536
537 data = %{
538 "nickname" => "GrimReaper",
539 "email" => "death@reapers.afterlife",
540 "fullname" => "Reaper Grim",
541 "bio" => "Your time has come",
542 "password" => "scythe",
543 "confirm" => "scythe",
544 "token" => invite.token
545 }
546
547 {:error, msg} = TwitterAPI.register_user(data)
548
549 assert msg == "Expired token"
550 refute User.get_by_nickname("GrimReaper")
551 end
552 end
553
554 describe "registers with reusable date limited token" do
555 setup do
556 setting = Pleroma.Config.get([:instance, :registrations_open])
557
558 if setting do
559 Pleroma.Config.put([:instance, :registrations_open], false)
560 on_exit(fn -> Pleroma.Config.put([:instance, :registrations_open], setting) end)
561 end
562
563 :ok
564 end
565
566 test "returns user on success" do
567 {:ok, invite} = UserInviteToken.create_invite(%{expires_at: Date.utc_today(), max_use: 100})
568
569 data = %{
570 "nickname" => "vinny",
571 "email" => "pasta@pizza.vs",
572 "fullname" => "Vinny Vinesauce",
573 "bio" => "streamer",
574 "password" => "hiptofbees",
575 "confirm" => "hiptofbees",
576 "token" => invite.token
577 }
578
579 {:ok, user} = TwitterAPI.register_user(data)
580 fetched_user = User.get_by_nickname("vinny")
581 invite = Repo.get_by(UserInviteToken, token: invite.token)
582
583 refute invite.used
584
585 assert UserView.render("show.json", %{user: user}) ==
586 UserView.render("show.json", %{user: fetched_user})
587 end
588
589 test "error after max uses" do
590 {:ok, invite} = UserInviteToken.create_invite(%{expires_at: Date.utc_today(), max_use: 100})
591
592 UserInviteToken.update_invite!(invite, uses: 99)
593
594 data = %{
595 "nickname" => "vinny",
596 "email" => "pasta@pizza.vs",
597 "fullname" => "Vinny Vinesauce",
598 "bio" => "streamer",
599 "password" => "hiptofbees",
600 "confirm" => "hiptofbees",
601 "token" => invite.token
602 }
603
604 {:ok, user} = TwitterAPI.register_user(data)
605 fetched_user = User.get_by_nickname("vinny")
606 invite = Repo.get_by(UserInviteToken, token: invite.token)
607 assert invite.used == true
608
609 assert UserView.render("show.json", %{user: user}) ==
610 UserView.render("show.json", %{user: fetched_user})
611
612 data = %{
613 "nickname" => "GrimReaper",
614 "email" => "death@reapers.afterlife",
615 "fullname" => "Reaper Grim",
616 "bio" => "Your time has come",
617 "password" => "scythe",
618 "confirm" => "scythe",
619 "token" => invite.token
620 }
621
622 {:error, msg} = TwitterAPI.register_user(data)
623
624 assert msg == "Expired token"
625 refute User.get_by_nickname("GrimReaper")
626 end
627
628 test "returns error on overdue date" do
629 {:ok, invite} =
630 UserInviteToken.create_invite(%{expires_at: Date.add(Date.utc_today(), -1), max_use: 100})
631
632 data = %{
633 "nickname" => "GrimReaper",
634 "email" => "death@reapers.afterlife",
635 "fullname" => "Reaper Grim",
636 "bio" => "Your time has come",
637 "password" => "scythe",
638 "confirm" => "scythe",
639 "token" => invite.token
640 }
641
642 {:error, msg} = TwitterAPI.register_user(data)
643
644 assert msg == "Expired token"
645 refute User.get_by_nickname("GrimReaper")
646 end
647
648 test "returns error on with overdue date and after max" do
649 {:ok, invite} =
650 UserInviteToken.create_invite(%{expires_at: Date.add(Date.utc_today(), -1), max_use: 100})
651
652 UserInviteToken.update_invite!(invite, uses: 100)
653
654 data = %{
655 "nickname" => "GrimReaper",
656 "email" => "death@reapers.afterlife",
657 "fullname" => "Reaper Grim",
658 "bio" => "Your time has come",
659 "password" => "scythe",
660 "confirm" => "scythe",
661 "token" => invite.token
662 }
663
664 {:error, msg} = TwitterAPI.register_user(data)
665
666 assert msg == "Expired token"
667 refute User.get_by_nickname("GrimReaper")
668 end
669 end
670
671 test "it returns the error on registration problems" do
672 data = %{
673 "nickname" => "lain",
674 "email" => "lain@wired.jp",
675 "fullname" => "lain iwakura",
676 "bio" => "close the world.",
677 "password" => "bear"
678 }
679
680 {:error, error_object} = TwitterAPI.register_user(data)
681
682 assert is_binary(error_object[:error])
683 refute User.get_by_nickname("lain")
684 end
685
686 test "it assigns an integer conversation_id" do
687 note_activity = insert(:note_activity)
688 status = ActivityView.render("activity.json", activity: note_activity)
689
690 assert is_number(status["statusnet_conversation_id"])
691 end
692
693 setup do
694 Supervisor.terminate_child(Pleroma.Supervisor, Cachex)
695 Supervisor.restart_child(Pleroma.Supervisor, Cachex)
696 :ok
697 end
698
699 describe "fetching a user by uri" do
700 test "fetches a user by uri" do
701 id = "https://mastodon.social/users/lambadalambda"
702 user = insert(:user)
703 {:ok, represented} = TwitterAPI.get_external_profile(user, id)
704 remote = User.get_by_ap_id(id)
705
706 assert represented["id"] == UserView.render("show.json", %{user: remote, for: user})["id"]
707
708 # Also fetches the feed.
709 # assert Activity.get_create_by_object_ap_id("tag:mastodon.social,2017-04-05:objectId=1641750:objectType=Status")
710 # credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
711 end
712 end
713 end