Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mozilla/reticulum
Browse files Browse the repository at this point in the history
  • Loading branch information
tanfarming committed May 10, 2024
2 parents f474321 + ab51827 commit 81cc6b5
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 7 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,26 @@ Navigate to that url in your browser to finish signing in.

### 6. Creating an Admin User

After you've started Reticulum for the first time you'll likely want to create an admin user. Assuming you want to make the first account the admin, this can be done in the iex console using the following code:

After you've started Reticulum for the first time you'll likely want to create an admin user. Assuming you want to make the first account the admin, this can be done in the iex console:
1) Open the iex console. From the reticulum folder run:
```
iex -S mix
```
2) Then run the following code:
```
Ret.Account |> Ret.Repo.all() |> Enum.at(0) |> Ecto.Changeset.change(is_admin: true) |> Ret.Repo.update!()
```

Make sure to run the Maybe try iex -S mix where the reticulum mix.exs file is.

### 7. Enabling Room Features

Rooms are created with restricted permissions by default, which means you can't spawn media objects. You can change this setting in the admin panel, or run the following code in the iex console:

1) Open the iex console. From the reticulum folder run:
```
iex -S mix
```
2) Then run the following code:
```
Ret.AppConfig.set_config_value("features|permissive_rooms", true)
```
Expand Down
33 changes: 31 additions & 2 deletions lib/ret/media_search.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ defmodule Ret.MediaSearch do
@max_collection_face_count 200_000

# see sketchfab bug about max_filesizes params broken
# @max_file_size_bytes 20 * 1024 * 1024
# @max_file_size_bytes 20 * 1024 * 1024
# @max_collection_file_size_bytes 100 * 1024 * 1024

def search(%Ret.MediaSearchQuery{
Expand Down Expand Up @@ -125,6 +125,16 @@ defmodule Ret.MediaSearch do
public_rooms_search(cursor, q)
end

def search(%Ret.MediaSearchQuery{
source: "rooms",
filter: "created",
cursor: cursor,
user: account_id,
q: q
}) do
created_rooms_search(cursor, account_id, q)
end

def search(%Ret.MediaSearchQuery{
source: "sketchfab",
cursor: cursor,
Expand Down Expand Up @@ -225,7 +235,7 @@ defmodule Ret.MediaSearch do
downloadable: true,
count: @page_size,
max_face_count: @max_face_count,
# max_filesizes: "gltf:#{@max_file_size_bytes}",
# max_filesizes: "gltf:#{@max_file_size_bytes}",
processing_status: :succeeded,
cursor: cursor,
categories: filter,
Expand Down Expand Up @@ -547,6 +557,25 @@ defmodule Ret.MediaSearch do
{:commit, results}
end

defp created_rooms_search(cursor, account_id, _query) do
page_number = (cursor || "1") |> Integer.parse() |> elem(0)
ecto_query =
from h in Hub,
where: h.created_by_account_id == ^account_id,
preload: [
scene: [:screenshot_owned_file],
scene_listing: [:scene, :screenshot_owned_file]
],
order_by: [desc: :inserted_at]

results =
ecto_query
|> Repo.paginate(%{page: page_number, page_size: @page_size})
|> result_for_page(page_number, :my_rooms, &hub_to_entry/1)

{:commit, results}
end

defp filter_by_hub_entry_mode(query, entry_mode) do
from fav in query,
join: hub in assoc(fav, :hub),
Expand Down
21 changes: 21 additions & 0 deletions lib/ret_web/controllers/api/v1/media_search_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@ defmodule RetWeb.Api.V1.MediaSearchController do
use RetWeb, :controller
use Retry

def index(conn, %{"source" => source, "filter" => "created", "user" => user} = params)
when source in ["rooms"] do
account = conn |> Guardian.Plug.current_resource()

if account && account.account_id == String.to_integer(user) do
{:commit, results} =
%Ret.MediaSearchQuery{
source: "rooms",
cursor: params["cursor"] || "1",
user: account.account_id,
filter: "created",
q: params["q"]
}
|> Ret.MediaSearch.search()

conn |> render("index.json", results: results)
else
conn |> send_resp(401, "You can only search created rooms for your own account.")
end
end

def index(conn, %{"source" => "rooms"} = params) do
{:commit, results} =
%Ret.MediaSearchQuery{
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ defmodule Ret.Mixfile do
{:scrivener_ecto, "~> 2.0"},
{:ua_parser, "~> 1.5"},
{:download, git: "https://github.com/gfodor/download.git", branch: "reticulum/master"},
{:reverse_proxy_plug, "~> 2.1"},
{:reverse_proxy_plug, "2.3.0"},
{:inet_cidr, "~> 1.0"},
{:dns, "~> 2.2.0"},
{:oauther, "~> 1.1"},
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"recon": {:hex, :recon, "2.5.0", "2f7fcbec2c35034bade2f9717f77059dc54eb4e929a3049ca7ba6775c0bd66cd", [:mix, :rebar3], [], "hexpm", "72f3840fedd94f06315c523f6cecf5b4827233bed7ae3fe135b2a0ebeab5e196"},
"retry": {:hex, :retry, "0.15.0", "ba6aaeba92905a396c18c299a07e638947b2ba781e914f803202bc1b9ae867c3", [:mix], [], "hexpm", "93d3310bce78c0a30cc94610684340a14adfc9136856a3f662e4d9ce6013c784"},
"reverse_proxy_plug": {:git, "https://github.com/mozillareality/reverse_proxy_plug.git", "271111467623ca1f45c3837b14c4ca0661db0f3e", [branch: "reticulum/master"]},
"reverse_proxy_plug": {:hex, :reverse_proxy_plug, "2.3.0", "6830ae83b383576899826d09ac00328e559455de650c9f047a413f1b64de450d", [:mix], [{:cowboy, "~> 2.4", [hex: :cowboy, repo: "hexpm", optional: false]}, {:httpoison, "~> 1.2 or ~> 2.0", [hex: :httpoison, repo: "hexpm", optional: true]}, {:plug, "~> 1.6", [hex: :plug, repo: "hexpm", optional: false]}, {:tesla, "~> 1.4", [hex: :tesla, repo: "hexpm", optional: true]}], "hexpm", "eb0007fb8fc6a4a1627c62270e2713e99bea31883daac77c85d60dd10dcdfdc3"},
"scrivener": {:hex, :scrivener, "2.7.0", "fa94cdea21fad0649921d8066b1833d18d296217bfdf4a5389a2f45ee857b773", [:mix], [], "hexpm", "30da36a427f2519cf75993271fb7c5aad1759682a70f90d880a85c3d743d2c57"},
"scrivener_ecto": {:hex, :scrivener_ecto, "2.3.0", "057f9dd3c77315f0a470263c3565353860d0294404aed611b3524c6df9044189", [:mix], [{:ecto, "~> 3.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:scrivener, "~> 2.4", [hex: :scrivener, repo: "hexpm", optional: false]}], "hexpm", "dfa43ca660651da63239e5d4acbfd9c57c5759bbf3a2bdc16cd70777c9bc7e0d"},
"secure_random": {:hex, :secure_random, "0.5.1", "c5532b37c89d175c328f5196a0c2a5680b15ebce3e654da37129a9fe40ebf51b", [:mix], [], "hexpm", "1b9754f15e3940a143baafd19da12293f100044df69ea12db5d72878312ae6ab"},
Expand Down

0 comments on commit 81cc6b5

Please sign in to comment.