1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42module rec Duets.Entities.SocialNetwork
open Duets.Common
/// Creates the initial state of all social networks for the given character
/// and band.
let empty =
{ Mastodon =
{ CurrentAccount = SocialNetworkCurrentAccountStatus.NoAccountCreated
Accounts = Map.empty } }
module Account =
let private removeTrailingAts handle =
if handle |> String.startsWith "@" then
handle.Substring 1
else
handle
/// Creates an empty social network account for the given ID.
let createEmpty id handle =
{ Id = id
Handle = handle |> removeTrailingAts
Followers = 0
Posts = List.empty }
/// Creates a social network account for the given ID with the handle and
/// followers specified.
let create id handle followers =
{ Id = id
Handle = handle |> removeTrailingAts
Followers = followers
Posts = List.empty }
module Post =
/// Creates a post the given account, date and text, with no reposts.
let create accountId date text =
{ Id = Identity.create ()
AccountId = accountId
Timestamp = date
Text = text
Reposts = 0 }