JlSonic/JlSonic/types.jl

54 lines
1.2 KiB
Julia
Raw Normal View History

2019-05-19 22:24:18 +02:00
import Random
2019-05-21 11:05:53 +02:00
import Dates
2019-05-17 20:22:01 +02:00
mutable struct User
name::String
2019-05-19 22:24:18 +02:00
password::String
2019-05-17 20:22:01 +02:00
email::String
# scrobbling::Bool
admin::Bool
settings::Bool
download::Bool
upload::Bool
cover::Bool
playlist::Bool
comment::Bool
# podcast::Bool
stream::Bool
# jukebox::Bool
share::Bool
end
2019-05-19 22:24:18 +02:00
mutable struct Playlist
uuid::String
name::String
comment::String
owner::String
public::Bool
# FIXME: replace with uuids only (and check they exists when importing)
songs::Vector{Song}
cover::String
allowed::Vector{String}
2019-05-21 11:05:53 +02:00
created::Dates.DateTime
2019-05-19 22:24:18 +02:00
end
2019-05-17 20:22:01 +02:00
function Playlist(owner::String
; uuid = string(UUIDs.uuid4()),
name = "New Playlist",
comment = "",
public = false,
songs = Song[],
2019-05-19 22:24:18 +02:00
cover = "",
2019-05-21 11:05:53 +02:00
allowed = String[],
creation = Dates.now())
Playlist(uuid,
name, comment, owner, public,
songs, cover,
allowed, creation)
2019-05-17 20:22:01 +02:00
end
function User(name::String)
2019-05-19 22:24:18 +02:00
User(name, Random.randstring(30),
string(name, "@", domain),
2019-05-17 20:22:01 +02:00
false, false, false, false, false, false, false, false, false)
end