f1cb6ec9dafd342fbe4d20625e720309540262a8
[akkoma] / lib / pleroma / web / mastodon_api / mastodon_api_controller.ex
1 defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
2 use Pleroma.Web, :controller
3 alias Pleroma.{Repo, Activity, User, Notification, Stats}
4 alias Pleroma.Web
5 alias Pleroma.Web.MastodonAPI.{StatusView, AccountView, MastodonView}
6 alias Pleroma.Web.ActivityPub.ActivityPub
7 alias Pleroma.Web.{CommonAPI, OStatus}
8 alias Pleroma.Web.OAuth.{Authorization, Token, App}
9 alias Comeonin.Pbkdf2
10 import Ecto.Query
11 require Logger
12
13 def create_app(conn, params) do
14 with cs <- App.register_changeset(%App{}, params) |> IO.inspect(),
15 {:ok, app} <- Repo.insert(cs) |> IO.inspect() do
16 res = %{
17 id: app.id,
18 client_id: app.client_id,
19 client_secret: app.client_secret
20 }
21
22 json(conn, res)
23 end
24 end
25
26 def update_credentials(%{assigns: %{user: user}} = conn, params) do
27 original_user = user
28
29 params =
30 if bio = params["note"] do
31 Map.put(params, "bio", bio)
32 else
33 params
34 end
35
36 params =
37 if name = params["display_name"] do
38 Map.put(params, "name", name)
39 else
40 params
41 end
42
43 user =
44 if avatar = params["avatar"] do
45 with %Plug.Upload{} <- avatar,
46 {:ok, object} <- ActivityPub.upload(avatar),
47 change = Ecto.Changeset.change(user, %{avatar: object.data}),
48 {:ok, user} = User.update_and_set_cache(change) do
49 user
50 else
51 _e -> user
52 end
53 else
54 user
55 end
56
57 user =
58 if banner = params["header"] do
59 with %Plug.Upload{} <- banner,
60 {:ok, object} <- ActivityPub.upload(banner),
61 new_info <- Map.put(user.info, "banner", object.data),
62 change <- User.info_changeset(user, %{info: new_info}),
63 {:ok, user} <- User.update_and_set_cache(change) do
64 user
65 else
66 _e -> user
67 end
68 else
69 user
70 end
71
72 with changeset <- User.update_changeset(user, params),
73 {:ok, user} <- User.update_and_set_cache(changeset) do
74 if original_user != user do
75 CommonAPI.update(user)
76 end
77
78 json(conn, AccountView.render("account.json", %{user: user}))
79 else
80 _e ->
81 conn
82 |> put_status(403)
83 |> json(%{error: "Invalid request"})
84 end
85 end
86
87 def verify_credentials(%{assigns: %{user: user}} = conn, _) do
88 account = AccountView.render("account.json", %{user: user})
89 json(conn, account)
90 end
91
92 def user(conn, %{"id" => id}) do
93 with %User{} = user <- Repo.get(User, id) do
94 account = AccountView.render("account.json", %{user: user})
95 json(conn, account)
96 else
97 _e ->
98 conn
99 |> put_status(404)
100 |> json(%{error: "Can't find user"})
101 end
102 end
103
104 @instance Application.get_env(:pleroma, :instance)
105 @mastodon_api_level "2.3.3"
106
107 def masto_instance(conn, _params) do
108 response = %{
109 uri: Web.base_url(),
110 title: Keyword.get(@instance, :name),
111 description: "A Pleroma instance, an alternative fediverse server",
112 version: "#{@mastodon_api_level} (compatible; #{Keyword.get(@instance, :version)})",
113 email: Keyword.get(@instance, :email),
114 urls: %{
115 streaming_api: String.replace(Web.base_url(), ["http", "https"], "wss")
116 },
117 stats: Stats.get_stats(),
118 thumbnail: Web.base_url() <> "/instance/thumbnail.jpeg",
119 max_toot_chars: Keyword.get(@instance, :limit)
120 }
121
122 json(conn, response)
123 end
124
125 def peers(conn, _params) do
126 json(conn, Stats.get_peers())
127 end
128
129 defp mastodonized_emoji do
130 Pleroma.Formatter.get_custom_emoji()
131 |> Enum.map(fn {shortcode, relative_url} ->
132 url = to_string(URI.merge(Web.base_url(), relative_url))
133
134 %{
135 "shortcode" => shortcode,
136 "static_url" => url,
137 "url" => url
138 }
139 end)
140 end
141
142 def custom_emojis(conn, _params) do
143 mastodon_emoji = mastodonized_emoji()
144 json(conn, mastodon_emoji)
145 end
146
147 defp add_link_headers(conn, method, activities, param \\ false) do
148 last = List.last(activities)
149 first = List.first(activities)
150
151 if last do
152 min = last.id
153 max = first.id
154
155 {next_url, prev_url} =
156 if param do
157 {
158 mastodon_api_url(Pleroma.Web.Endpoint, method, param, max_id: min),
159 mastodon_api_url(Pleroma.Web.Endpoint, method, param, since_id: max)
160 }
161 else
162 {
163 mastodon_api_url(Pleroma.Web.Endpoint, method, max_id: min),
164 mastodon_api_url(Pleroma.Web.Endpoint, method, since_id: max)
165 }
166 end
167
168 conn
169 |> put_resp_header("link", "<#{next_url}>; rel=\"next\", <#{prev_url}>; rel=\"prev\"")
170 else
171 conn
172 end
173 end
174
175 def home_timeline(%{assigns: %{user: user}} = conn, params) do
176 params =
177 params
178 |> Map.put("type", ["Create", "Announce"])
179 |> Map.put("blocking_user", user)
180 |> Map.put("user", user)
181
182 activities =
183 ActivityPub.fetch_activities([user.ap_id | user.following], params)
184 |> Enum.reverse()
185
186 conn
187 |> add_link_headers(:home_timeline, activities)
188 |> render(StatusView, "index.json", %{activities: activities, for: user, as: :activity})
189 end
190
191 def public_timeline(%{assigns: %{user: user}} = conn, params) do
192 params =
193 params
194 |> Map.put("type", ["Create", "Announce"])
195 |> Map.put("local_only", params["local"] in [true, "True", "true", "1"])
196 |> Map.put("blocking_user", user)
197
198 activities =
199 ActivityPub.fetch_public_activities(params)
200 |> Enum.reverse()
201
202 conn
203 |> add_link_headers(:public_timeline, activities)
204 |> render(StatusView, "index.json", %{activities: activities, for: user, as: :activity})
205 end
206
207 def user_statuses(%{assigns: %{user: user}} = conn, params) do
208 with %User{ap_id: ap_id} <- Repo.get(User, params["id"]) do
209 params =
210 params
211 |> Map.put("type", ["Create", "Announce"])
212 |> Map.put("actor_id", ap_id)
213 |> Map.put("whole_db", true)
214
215 activities =
216 ActivityPub.fetch_public_activities(params)
217 |> Enum.reverse()
218
219 conn
220 |> add_link_headers(:user_statuses, activities, params["id"])
221 |> render(StatusView, "index.json", %{activities: activities, for: user, as: :activity})
222 end
223 end
224
225 def get_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do
226 with %Activity{} = activity <- Repo.get(Activity, id),
227 true <- ActivityPub.visible_for_user?(activity, user) do
228 render(conn, StatusView, "status.json", %{activity: activity, for: user})
229 end
230 end
231
232 def get_context(%{assigns: %{user: user}} = conn, %{"id" => id}) do
233 with %Activity{} = activity <- Repo.get(Activity, id),
234 activities <-
235 ActivityPub.fetch_activities_for_context(activity.data["context"], %{
236 "blocking_user" => user,
237 "user" => user
238 }),
239 activities <-
240 activities |> Enum.filter(fn %{id: aid} -> to_string(aid) != to_string(id) end),
241 activities <-
242 activities |> Enum.filter(fn %{data: %{"type" => type}} -> type == "Create" end),
243 grouped_activities <- Enum.group_by(activities, fn %{id: id} -> id < activity.id end) do
244 result = %{
245 ancestors:
246 StatusView.render(
247 "index.json",
248 for: user,
249 activities: grouped_activities[true] || [],
250 as: :activity
251 )
252 |> Enum.reverse(),
253 descendants:
254 StatusView.render(
255 "index.json",
256 for: user,
257 activities: grouped_activities[false] || [],
258 as: :activity
259 )
260 |> Enum.reverse()
261 }
262
263 json(conn, result)
264 end
265 end
266
267 def post_status(%{assigns: %{user: user}} = conn, %{"status" => _} = params) do
268 params =
269 params
270 |> Map.put("in_reply_to_status_id", params["in_reply_to_id"])
271 |> Map.put("no_attachment_links", true)
272
273 {:ok, activity} = CommonAPI.post(user, params)
274 render(conn, StatusView, "status.json", %{activity: activity, for: user, as: :activity})
275 end
276
277 def delete_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do
278 with {:ok, %Activity{}} <- CommonAPI.delete(id, user) do
279 json(conn, %{})
280 else
281 _e ->
282 conn
283 |> put_status(403)
284 |> json(%{error: "Can't delete this post"})
285 end
286 end
287
288 def reblog_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do
289 with {:ok, announce, _activity} = CommonAPI.repeat(ap_id_or_id, user) do
290 render(conn, StatusView, "status.json", %{activity: announce, for: user, as: :activity})
291 end
292 end
293
294 def fav_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do
295 with {:ok, _fav, %{data: %{"id" => id}}} = CommonAPI.favorite(ap_id_or_id, user),
296 %Activity{} = activity <- Activity.get_create_activity_by_object_ap_id(id) do
297 render(conn, StatusView, "status.json", %{activity: activity, for: user, as: :activity})
298 end
299 end
300
301 def unfav_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do
302 with {:ok, %{data: %{"id" => id}}} = CommonAPI.unfavorite(ap_id_or_id, user),
303 %Activity{} = activity <- Activity.get_create_activity_by_object_ap_id(id) do
304 render(conn, StatusView, "status.json", %{activity: activity, for: user, as: :activity})
305 end
306 end
307
308 def notifications(%{assigns: %{user: user}} = conn, params) do
309 notifications = Notification.for_user(user, params)
310
311 result =
312 Enum.map(notifications, fn x ->
313 render_notification(user, x)
314 end)
315 |> Enum.filter(& &1)
316
317 conn
318 |> add_link_headers(:notifications, notifications)
319 |> json(result)
320 end
321
322 def get_notification(%{assigns: %{user: user}} = conn, %{"id" => id} = _params) do
323 with {:ok, notification} <- Notification.get(user, id) do
324 json(conn, render_notification(user, notification))
325 else
326 {:error, reason} ->
327 conn
328 |> put_resp_content_type("application/json")
329 |> send_resp(403, Jason.encode!(%{"error" => reason}))
330 end
331 end
332
333 def clear_notifications(%{assigns: %{user: user}} = conn, _params) do
334 Notification.clear(user)
335 json(conn, %{})
336 end
337
338 def dismiss_notification(%{assigns: %{user: user}} = conn, %{"id" => id} = _params) do
339 with {:ok, _notif} <- Notification.dismiss(user, id) do
340 json(conn, %{})
341 else
342 {:error, reason} ->
343 conn
344 |> put_resp_content_type("application/json")
345 |> send_resp(403, Jason.encode!(%{"error" => reason}))
346 end
347 end
348
349 def relationships(%{assigns: %{user: user}} = conn, %{"id" => id}) do
350 id = List.wrap(id)
351 q = from(u in User, where: u.id in ^id)
352 targets = Repo.all(q)
353 render(conn, AccountView, "relationships.json", %{user: user, targets: targets})
354 end
355
356 def upload(%{assigns: %{user: _}} = conn, %{"file" => file}) do
357 with {:ok, object} <- ActivityPub.upload(file) do
358 data =
359 object.data
360 |> Map.put("id", object.id)
361
362 render(conn, StatusView, "attachment.json", %{attachment: data})
363 end
364 end
365
366 def favourited_by(conn, %{"id" => id}) do
367 with %Activity{data: %{"object" => %{"likes" => likes}}} <- Repo.get(Activity, id) do
368 q = from(u in User, where: u.ap_id in ^likes)
369 users = Repo.all(q)
370 render(conn, AccountView, "accounts.json", %{users: users, as: :user})
371 else
372 _ -> json(conn, [])
373 end
374 end
375
376 def reblogged_by(conn, %{"id" => id}) do
377 with %Activity{data: %{"object" => %{"announcements" => announces}}} <- Repo.get(Activity, id) do
378 q = from(u in User, where: u.ap_id in ^announces)
379 users = Repo.all(q)
380 render(conn, AccountView, "accounts.json", %{users: users, as: :user})
381 else
382 _ -> json(conn, [])
383 end
384 end
385
386 def hashtag_timeline(%{assigns: %{user: user}} = conn, params) do
387 params =
388 params
389 |> Map.put("type", "Create")
390 |> Map.put("local_only", !!params["local"])
391 |> Map.put("blocking_user", user)
392
393 activities =
394 ActivityPub.fetch_public_activities(params)
395 |> Enum.reverse()
396
397 conn
398 |> add_link_headers(:hashtag_timeline, activities, params["tag"])
399 |> render(StatusView, "index.json", %{activities: activities, for: user, as: :activity})
400 end
401
402 # TODO: Pagination
403 def followers(conn, %{"id" => id}) do
404 with %User{} = user <- Repo.get(User, id),
405 {:ok, followers} <- User.get_followers(user) do
406 render(conn, AccountView, "accounts.json", %{users: followers, as: :user})
407 end
408 end
409
410 def following(conn, %{"id" => id}) do
411 with %User{} = user <- Repo.get(User, id),
412 {:ok, followers} <- User.get_friends(user) do
413 render(conn, AccountView, "accounts.json", %{users: followers, as: :user})
414 end
415 end
416
417 def follow(%{assigns: %{user: follower}} = conn, %{"id" => id}) do
418 with %User{} = followed <- Repo.get(User, id),
419 {:ok, follower} <- User.follow(follower, followed),
420 {:ok, _activity} <- ActivityPub.follow(follower, followed) do
421 render(conn, AccountView, "relationship.json", %{user: follower, target: followed})
422 else
423 {:error, message} ->
424 conn
425 |> put_resp_content_type("application/json")
426 |> send_resp(403, Jason.encode!(%{"error" => message}))
427 end
428 end
429
430 def follow(%{assigns: %{user: follower}} = conn, %{"uri" => uri}) do
431 with %User{} = followed <- Repo.get_by(User, nickname: uri),
432 {:ok, follower} <- User.follow(follower, followed),
433 {:ok, _activity} <- ActivityPub.follow(follower, followed) do
434 render(conn, AccountView, "account.json", %{user: followed})
435 else
436 {:error, message} ->
437 conn
438 |> put_resp_content_type("application/json")
439 |> send_resp(403, Jason.encode!(%{"error" => message}))
440 end
441 end
442
443 # TODO: Clean up and unify
444 def unfollow(%{assigns: %{user: follower}} = conn, %{"id" => id}) do
445 with %User{} = followed <- Repo.get(User, id),
446 {:ok, follower, follow_activity} <- User.unfollow(follower, followed),
447 {:ok, _activity} <-
448 ActivityPub.insert(%{
449 "type" => "Undo",
450 "actor" => follower.ap_id,
451 # get latest Follow for these users
452 "object" => follow_activity.data["id"]
453 }) do
454 render(conn, AccountView, "relationship.json", %{user: follower, target: followed})
455 end
456 end
457
458 def block(%{assigns: %{user: blocker}} = conn, %{"id" => id}) do
459 with %User{} = blocked <- Repo.get(User, id),
460 {:ok, blocker} <- User.block(blocker, blocked) do
461 render(conn, AccountView, "relationship.json", %{user: blocker, target: blocked})
462 else
463 {:error, message} ->
464 conn
465 |> put_resp_content_type("application/json")
466 |> send_resp(403, Jason.encode!(%{"error" => message}))
467 end
468 end
469
470 def unblock(%{assigns: %{user: blocker}} = conn, %{"id" => id}) do
471 with %User{} = blocked <- Repo.get(User, id),
472 {:ok, blocker} <- User.unblock(blocker, blocked) do
473 render(conn, AccountView, "relationship.json", %{user: blocker, target: blocked})
474 else
475 {:error, message} ->
476 conn
477 |> put_resp_content_type("application/json")
478 |> send_resp(403, Jason.encode!(%{"error" => message}))
479 end
480 end
481
482 # TODO: Use proper query
483 def blocks(%{assigns: %{user: user}} = conn, _) do
484 with blocked_users <- user.info["blocks"] || [],
485 accounts <- Enum.map(blocked_users, fn ap_id -> User.get_cached_by_ap_id(ap_id) end) do
486 res = AccountView.render("accounts.json", users: accounts, for: user, as: :user)
487 json(conn, res)
488 end
489 end
490
491 def search(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do
492 accounts = User.search(query, params["resolve"] == "true")
493
494 fetched =
495 if Regex.match?(~r/https?:/, query) do
496 with {:ok, activities} <- OStatus.fetch_activity_from_url(query) do
497 activities
498 |> Enum.filter(fn
499 %{data: %{"type" => "Create"}} -> true
500 _ -> false
501 end)
502 else
503 _e -> []
504 end
505 end || []
506
507 q =
508 from(
509 a in Activity,
510 where: fragment("?->>'type' = 'Create'", a.data),
511 where: "https://www.w3.org/ns/activitystreams#Public" in a.recipients,
512 where:
513 fragment(
514 "to_tsvector('english', ?->'object'->>'content') @@ plainto_tsquery('english', ?)",
515 a.data,
516 ^query
517 ),
518 limit: 20
519 )
520
521 statuses = Repo.all(q) ++ fetched
522
523 tags =
524 String.split(query)
525 |> Enum.uniq()
526 |> Enum.filter(fn tag -> String.starts_with?(tag, "#") end)
527 |> Enum.map(fn tag -> String.slice(tag, 1..-1) end)
528
529 res = %{
530 "accounts" => AccountView.render("accounts.json", users: accounts, for: user, as: :user),
531 "statuses" =>
532 StatusView.render("index.json", activities: statuses, for: user, as: :activity),
533 "hashtags" => tags
534 }
535
536 json(conn, res)
537 end
538
539 def account_search(%{assigns: %{user: user}} = conn, %{"q" => query} = params) do
540 accounts = User.search(query, params["resolve"] == "true")
541
542 res = AccountView.render("accounts.json", users: accounts, for: user, as: :user)
543
544 json(conn, res)
545 end
546
547 def favourites(%{assigns: %{user: user}} = conn, _) do
548 params =
549 %{}
550 |> Map.put("type", "Create")
551 |> Map.put("favorited_by", user.ap_id)
552 |> Map.put("blocking_user", user)
553
554 activities =
555 ActivityPub.fetch_public_activities(params)
556 |> Enum.reverse()
557
558 conn
559 |> render(StatusView, "index.json", %{activities: activities, for: user, as: :activity})
560 end
561
562 def index(%{assigns: %{user: user}} = conn, _params) do
563 token =
564 conn
565 |> get_session(:oauth_token)
566
567 if user && token do
568 mastodon_emoji = mastodonized_emoji()
569 accounts = Map.put(%{}, user.id, AccountView.render("account.json", %{user: user}))
570
571 initial_state =
572 %{
573 meta: %{
574 streaming_api_base_url:
575 String.replace(Pleroma.Web.Endpoint.static_url(), "http", "ws"),
576 access_token: token,
577 locale: "en",
578 domain: Pleroma.Web.Endpoint.host(),
579 admin: "1",
580 me: "#{user.id}",
581 unfollow_modal: false,
582 boost_modal: false,
583 delete_modal: true,
584 auto_play_gif: false,
585 reduce_motion: false
586 },
587 compose: %{
588 me: "#{user.id}",
589 default_privacy: "public",
590 default_sensitive: false
591 },
592 media_attachments: %{
593 accept_content_types: [
594 ".jpg",
595 ".jpeg",
596 ".png",
597 ".gif",
598 ".webm",
599 ".mp4",
600 ".m4v",
601 "image\/jpeg",
602 "image\/png",
603 "image\/gif",
604 "video\/webm",
605 "video\/mp4"
606 ]
607 },
608 settings: %{
609 onboarded: true,
610 home: %{
611 shows: %{
612 reblog: true,
613 reply: true
614 }
615 },
616 notifications: %{
617 alerts: %{
618 follow: true,
619 favourite: true,
620 reblog: true,
621 mention: true
622 },
623 shows: %{
624 follow: true,
625 favourite: true,
626 reblog: true,
627 mention: true
628 },
629 sounds: %{
630 follow: true,
631 favourite: true,
632 reblog: true,
633 mention: true
634 }
635 }
636 },
637 push_subscription: nil,
638 accounts: accounts,
639 custom_emojis: mastodon_emoji,
640 char_limit: Keyword.get(@instance, :limit)
641 }
642 |> Jason.encode!()
643
644 conn
645 |> put_layout(false)
646 |> render(MastodonView, "index.html", %{initial_state: initial_state})
647 else
648 conn
649 |> redirect(to: "/web/login")
650 end
651 end
652
653 def login(conn, _) do
654 conn
655 |> render(MastodonView, "login.html", %{error: false})
656 end
657
658 defp get_or_make_app() do
659 with %App{} = app <- Repo.get_by(App, client_name: "Mastodon-Local") do
660 {:ok, app}
661 else
662 _e ->
663 cs =
664 App.register_changeset(%App{}, %{
665 client_name: "Mastodon-Local",
666 redirect_uris: ".",
667 scopes: "read,write,follow"
668 })
669
670 Repo.insert(cs)
671 end
672 end
673
674 def login_post(conn, %{"authorization" => %{"name" => name, "password" => password}}) do
675 with %User{} = user <- User.get_cached_by_nickname(name),
676 true <- Pbkdf2.checkpw(password, user.password_hash),
677 {:ok, app} <- get_or_make_app(),
678 {:ok, auth} <- Authorization.create_authorization(app, user),
679 {:ok, token} <- Token.exchange_token(app, auth) do
680 conn
681 |> put_session(:oauth_token, token.token)
682 |> redirect(to: "/web/getting-started")
683 else
684 _e ->
685 conn
686 |> render(MastodonView, "login.html", %{error: "Wrong username or password"})
687 end
688 end
689
690 def logout(conn, _) do
691 conn
692 |> clear_session
693 |> redirect(to: "/")
694 end
695
696 def relationship_noop(%{assigns: %{user: user}} = conn, %{"id" => id}) do
697 Logger.debug("Unimplemented, returning unmodified relationship")
698
699 with %User{} = target <- Repo.get(User, id) do
700 render(conn, AccountView, "relationship.json", %{user: user, target: target})
701 end
702 end
703
704 def empty_array(conn, _) do
705 Logger.debug("Unimplemented, returning an empty array")
706 json(conn, [])
707 end
708
709 def empty_object(conn, _) do
710 Logger.debug("Unimplemented, returning an empty object")
711 json(conn, %{})
712 end
713
714 def render_notification(user, %{id: id, activity: activity, inserted_at: created_at} = _params) do
715 actor = User.get_cached_by_ap_id(activity.data["actor"])
716
717 created_at =
718 NaiveDateTime.to_iso8601(created_at)
719 |> String.replace(~r/(\.\d+)?$/, ".000Z", global: false)
720
721 case activity.data["type"] do
722 "Create" ->
723 %{
724 id: id,
725 type: "mention",
726 created_at: created_at,
727 account: AccountView.render("account.json", %{user: actor}),
728 status: StatusView.render("status.json", %{activity: activity, for: user})
729 }
730
731 "Like" ->
732 liked_activity = Activity.get_create_activity_by_object_ap_id(activity.data["object"])
733
734 %{
735 id: id,
736 type: "favourite",
737 created_at: created_at,
738 account: AccountView.render("account.json", %{user: actor}),
739 status: StatusView.render("status.json", %{activity: liked_activity, for: user})
740 }
741
742 "Announce" ->
743 announced_activity = Activity.get_create_activity_by_object_ap_id(activity.data["object"])
744
745 %{
746 id: id,
747 type: "reblog",
748 created_at: created_at,
749 account: AccountView.render("account.json", %{user: actor}),
750 status: StatusView.render("status.json", %{activity: announced_activity, for: user})
751 }
752
753 "Follow" ->
754 %{
755 id: id,
756 type: "follow",
757 created_at: created_at,
758 account: AccountView.render("account.json", %{user: actor})
759 }
760
761 _ ->
762 nil
763 end
764 end
765 end