2022-01-08 14:44:37 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.MastoFEView do
|
|
|
|
use Pleroma.Web, :view
|
|
|
|
alias Pleroma.Config
|
|
|
|
alias Pleroma.User
|
|
|
|
alias Pleroma.Web.MastodonAPI.AccountView
|
|
|
|
alias Pleroma.Web.MastodonAPI.CustomEmojiView
|
|
|
|
|
|
|
|
def initial_state(token, user, custom_emojis) do
|
|
|
|
limit = Config.get([:instance, :limit])
|
|
|
|
|
|
|
|
%{
|
|
|
|
meta: %{
|
2022-08-16 18:22:59 -06:00
|
|
|
title: Config.get([:instance, :name]),
|
2022-01-08 14:44:37 -07:00
|
|
|
streaming_api_base_url: Pleroma.Web.Endpoint.websocket_url(),
|
|
|
|
access_token: token,
|
|
|
|
locale: "en",
|
|
|
|
domain: Pleroma.Web.Endpoint.host(),
|
|
|
|
admin: "1",
|
|
|
|
me: "#{user.id}",
|
|
|
|
unfollow_modal: false,
|
|
|
|
boost_modal: false,
|
|
|
|
delete_modal: true,
|
|
|
|
auto_play_gif: false,
|
|
|
|
display_sensitive_media: false,
|
|
|
|
reduce_motion: false,
|
|
|
|
max_toot_chars: limit,
|
2022-08-16 18:22:59 -06:00
|
|
|
mascot: User.get_mascot(user)["url"],
|
|
|
|
show_quote_button: true,
|
|
|
|
enable_reaction: true,
|
|
|
|
compact_reaction: false,
|
|
|
|
advanced_layout: true
|
2022-01-08 14:44:37 -07:00
|
|
|
},
|
|
|
|
poll_limits: Config.get([:instance, :poll_limits]),
|
|
|
|
rights: %{
|
|
|
|
delete_others_notice: present?(user.is_moderator),
|
|
|
|
admin: present?(user.is_admin)
|
|
|
|
},
|
|
|
|
compose: %{
|
|
|
|
me: "#{user.id}",
|
|
|
|
default_privacy: user.default_scope,
|
|
|
|
default_sensitive: false,
|
|
|
|
allow_content_types: Config.get([:instance, :allowed_post_formats])
|
|
|
|
},
|
|
|
|
media_attachments: %{
|
|
|
|
accept_content_types: [
|
|
|
|
".jpg",
|
|
|
|
".jpeg",
|
|
|
|
".png",
|
|
|
|
".gif",
|
|
|
|
".webm",
|
|
|
|
".mp4",
|
|
|
|
".m4v",
|
|
|
|
"image\/jpeg",
|
|
|
|
"image\/png",
|
|
|
|
"image\/gif",
|
|
|
|
"video\/webm",
|
|
|
|
"video\/mp4"
|
|
|
|
]
|
|
|
|
},
|
2022-08-16 18:22:59 -06:00
|
|
|
lists: [],
|
2022-01-08 14:44:37 -07:00
|
|
|
settings: user.mastofe_settings || %{},
|
|
|
|
push_subscription: nil,
|
|
|
|
accounts: %{user.id => render(AccountView, "show.json", user: user, for: user)},
|
|
|
|
custom_emojis: render(CustomEmojiView, "index.json", custom_emojis: custom_emojis),
|
|
|
|
char_limit: limit
|
|
|
|
}
|
|
|
|
|> Jason.encode!()
|
|
|
|
|> Phoenix.HTML.raw()
|
|
|
|
end
|
|
|
|
|
|
|
|
defp present?(nil), do: false
|
|
|
|
defp present?(false), do: false
|
|
|
|
defp present?(_), do: true
|
|
|
|
|
|
|
|
def render("manifest.json", _params) do
|
|
|
|
%{
|
|
|
|
name: Config.get([:instance, :name]),
|
|
|
|
description: Config.get([:instance, :description]),
|
|
|
|
icons: Config.get([:manifest, :icons]),
|
|
|
|
theme_color: Config.get([:manifest, :theme_color]),
|
|
|
|
background_color: Config.get([:manifest, :background_color]),
|
|
|
|
display: "standalone",
|
|
|
|
scope: Pleroma.Web.Endpoint.url(),
|
2023-08-15 04:22:18 -06:00
|
|
|
start_url: ~p"/web/getting-started",
|
2022-01-08 14:44:37 -07:00
|
|
|
categories: [
|
|
|
|
"social"
|
|
|
|
],
|
|
|
|
serviceworker: %{
|
|
|
|
src: "/sw.js"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|