Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
name: Docker
on:
push:
branches:
- master
tags:
- '*'
- 'v*'
pull_request:
branches:
- master
schedule:
- cron: '0 0 * * 6' # every Saturday

jobs:
publish:
Expand All @@ -18,3 +25,4 @@ jobs:
repository: codingteam/emulsion
tag_with_ref: true
tags: latest
push: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') && 'true' || 'false' }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ out/

emulsion.json

*.db
*.db-shm
*.db-wal
*.user

.fake
.ionide
.ionide
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic
Versioning v2.0.0](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- [#147: Telegram content redirector support](https://github.com/codingteam/emulsion/issues/147). Emulsion is now able to generate redirects to t.me from its own embedded web server, knowing the internal content id.

This feature is not very useful, yet (earlier, the same t.me links were already available to the users directly), but it is the first step for further development of more valuable forms of content proxying.

## [1.9.0] - 2022-06-01
### Changed
- Runtime: upgrade to .NET 6
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app

COPY ./Emulsion/Emulsion.fsproj ./Emulsion/
COPY ./Emulsion.ContentProxy/Emulsion.ContentProxy.fsproj ./Emulsion.ContentProxy/
COPY ./Emulsion.Database/Emulsion.Database.fsproj ./Emulsion.Database/
COPY ./Emulsion/Emulsion.fsproj ./Emulsion/
COPY ./Emulsion.Settings/Emulsion.Settings.fsproj ./Emulsion.Settings/
COPY ./Emulsion.Web/Emulsion.Web.fsproj ./Emulsion.Web/

RUN dotnet restore Emulsion

Expand Down
4 changes: 2 additions & 2 deletions Emulsion.ContentProxy/ContentStorage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ let getOrCreateMessageRecord (context: EmulsionDbContext) (id: MessageContentIde
| Some item -> return item
}

let getById (context: EmulsionDbContext) (id: int64): Async<TelegramContent> = async {
let getById (context: EmulsionDbContext) (id: int64): Async<TelegramContent option> = async {
return! query {
for content in context.TelegramContents do
where (content.Id = id)
} |> exactlyOneAsync
} |> tryExactlyOneAsync
}
16 changes: 16 additions & 0 deletions Emulsion.Settings/Emulsion.Settings.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<Compile Include="Settings.fs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Emulsion.Database\Emulsion.Database.fsproj" />
</ItemGroup>

</Project>
17 changes: 10 additions & 7 deletions Emulsion/Settings.fs → Emulsion.Settings/Settings.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ type LogSettings = {
}

type HostingSettings = {
BaseUri: Uri
ExternalUriBase: Uri
BindUri: Uri
HashIdSalt: string
}

Expand Down Expand Up @@ -78,16 +79,18 @@ let read (config : IConfiguration) : EmulsionSettings =
|> Option.ofObj
|> Option.map(fun dataSource -> { DataSource = dataSource })
let readHosting(section: IConfigurationSection) =
let baseUri = Option.ofObj section["baseUri"]
let externalUriBase = Option.ofObj section["externalUriBase"]
let bindUri = Option.ofObj section["bindUri"]
let hashIdSalt = Option.ofObj section["hashIdSalt"]
match baseUri, hashIdSalt with
| Some baseUri, Some hashIdSalt ->
match externalUriBase, bindUri, hashIdSalt with
| Some externalUriBase, Some bindUri, Some hashIdSalt ->
Some {
BaseUri = Uri baseUri
ExternalUriBase = Uri externalUriBase
BindUri = Uri bindUri
HashIdSalt = hashIdSalt
}
| None, None -> None
| other -> failwith $"Pair {other} is not valid for hosting settings"
| None, None, None -> None
| other -> failwith $"Parameter pack {other} represents invalid hosting settings."

{ Xmpp = readXmpp <| config.GetSection("xmpp")
Telegram = readTelegram <| config.GetSection("telegram")
Expand Down
2 changes: 1 addition & 1 deletion Emulsion.Tests/Emulsion.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<Compile Include="Telegram\Html.fs" />
<Compile Include="Telegram\FunogramTests.fs" />
<Compile Include="Telegram\LinkGeneratorTests.fs" />
<Compile Include="Xmpp\SharpXmppPingHandlerTests.fs" />
<Compile Include="Xmpp\XmppClientFactory.fs" />
<Compile Include="Xmpp\XmppMessageFactory.fs" />
<Compile Include="Xmpp\XmppClientTests.fs" />
Expand All @@ -33,6 +32,7 @@
<Compile Include="Database\DatabaseStructureTests.fs" />
<Compile Include="ContentProxy\ContentStorageTests.fs" />
<Compile Include="ContentProxy\ProxyTests.fs" />
<Compile Include="Web\ContentControllerTests.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Akka.TestKit" Version="1.3.12" />
Expand Down
6 changes: 4 additions & 2 deletions Emulsion.Tests/SettingsTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ let ``Extended settings read properly``(): Task = task {
""dataSource"": "":memory:""
},
""hosting"": {
""baseUri"": ""https://example.com"",
""externalUriBase"": ""https://example.com"",
""bindUri"": ""http://localhost:5555"",
""hashIdSalt"": ""123123123""
}"
let expectedConfiguration =
Expand All @@ -90,7 +91,8 @@ let ``Extended settings read properly``(): Task = task {
DataSource = ":memory:"
}
Hosting = Some {
BaseUri = Uri("https://example.com")
ExternalUriBase = Uri "https://example.com"
BindUri = Uri "http://localhost:5555"
HashIdSalt = "123123123"
}
}
Expand Down
Loading