diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9ee1bf5..150b12d 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,6 @@ # Release Notes -## 1.0.0 - 2018-12-18 +## 1.0.3 - 2018-12-21 * Christmas edition ## 0.16.25 - 2018-12-18 diff --git a/src/Client/ReleaseNotes.fs b/src/Client/ReleaseNotes.fs index b2ff262..5a0d398 100644 --- a/src/Client/ReleaseNotes.fs +++ b/src/Client/ReleaseNotes.fs @@ -1,13 +1,13 @@ module internal ReleaseNotes -let Version = "1.0.0" +let Version = "1.0.3" let IsPrerelease = false let Notes = """ # Release Notes -## 1.0.0 - 2018-12-18 +## 1.0.3 - 2018-12-21 * Christmas edition ## 0.16.25 - 2018-12-18 diff --git a/src/Server/AzureTable.fs b/src/Server/AzureTable.fs index 5d95036..78ca340 100644 --- a/src/Server/AzureTable.fs +++ b/src/Server/AzureTable.fs @@ -130,6 +130,7 @@ let requestsTable = getTable "requests" connection open ServerCore.Domain open Thoth.Json.Net +open System let mapLink (entity: DynamicTableEntity) : Link = @@ -141,6 +142,7 @@ let mapTag (entity: DynamicTableEntity) : Tag = { Token = entity.RowKey Description = getStringProperty "Description" entity Object = getStringProperty "Object" entity + LastVerified = getOptionalDateTimeOffsetProperty "LastVerified" entity |> Option.defaultValue DateTimeOffset.MinValue Action = match Decode.fromString TagAction.Decoder (getStringProperty "Action" entity) with | Error msg -> failwith msg @@ -154,6 +156,7 @@ let saveTag (userID:string) (tag:Tag) = entity.Properties.["Action"] <- EntityProperty.GeneratePropertyForString (TagAction.Encoder tag.Action |> Encode.toString 0) entity.Properties.["Description"] <- EntityProperty.GeneratePropertyForString tag.Description entity.Properties.["Object"] <- EntityProperty.GeneratePropertyForString tag.Object + entity.Properties.["LastVerified"] <- EntityProperty.GeneratePropertyForDateTimeOffset(Nullable tag.LastVerified) let operation = TableOperation.InsertOrReplace entity tagsTable.ExecuteAsync operation diff --git a/src/Server/Server.fs b/src/Server/Server.fs index 1bc1724..e9dafa3 100644 --- a/src/Server/Server.fs +++ b/src/Server/Server.fs @@ -85,11 +85,7 @@ let discoverYoutubeLink (youtubeURL:string) = task { lines.Add line let lines = Seq.toArray lines - let links = - lines - |> Array.filter (fun x -> x.Contains "&mime=audio") - - return youtubeURL,links + return youtubeURL,lines } let mapYoutube (tag:Tag) = task { @@ -113,7 +109,12 @@ let uploadEndpoint (token:string) = let file = form.Files.[0] use stream = file.OpenReadStream() let! tagAction = uploadMusik stream - let tag : Tag = { Token = System.Guid.NewGuid().ToString(); Action = tagAction; Description = ""; Object = "" } + let tag : Tag = { + Token = System.Guid.NewGuid().ToString() + Action = tagAction + Description = "" + LastVerified = DateTimeOffset.UtcNow + Object = "" } let! _saved = AzureTable.saveTag token tag let! tag = mapBlobMusikTag tag let txt = Tag.Encoder tag |> Encode.toString 0 @@ -130,7 +131,14 @@ let tagEndpoint (userID,token) = let! tag = match tag with | Some t -> t |> mapBlobMusikTag - | _ -> task { return { Token = token; Action = TagAction.UnknownTag; Description = ""; Object = "" } } + | _ -> + let t = { + Token = token + Action = TagAction.UnknownTag + LastVerified = DateTimeOffset.MinValue + Description = "" + Object = "" } + task { return t } let! tag = tag |> mapYoutube let tag : TagForBox = { @@ -187,6 +195,16 @@ let firmwareEndpoint = }) } +let youtubeEndpoint = + pipeline { + set_header "Content-Type" "application/json" + plug (fun next ctx -> task { + let! _,urls = discoverYoutubeLink "https://www.youtube.com/watch?v=n2FHn3B0K4U" + let txt = sprintf "%A" urls + return! setBodyFromString txt next ctx + }) + } + let tagHistoryBroadcaster = ConnectionManager() let t = task { @@ -203,6 +221,7 @@ let webApp = postf "/api/upload/%s" uploadEndpoint get "/api/startup" startupEndpoint get "/api/firmware" firmwareEndpoint + get "/api/youtube" youtubeEndpoint get "/api/latestfirmware" getLatestFirmware getf "/api/taghistorysocket/%s" (TagHistorySocket.openSocket tagHistoryBroadcaster) } @@ -232,6 +251,9 @@ let discoverTask = task { match tag.Action with | TagAction.PlayYoutube url -> let! _,urls = discoverYoutubeLink url + let urls = + urls + |> Array.filter (fun x -> x.Contains "&mime=audio") let! _ = saveLinks tag urls () | _ -> () diff --git a/src/Shared/Shared.fs b/src/Shared/Shared.fs index 969b3a9..b614468 100644 --- a/src/Shared/Shared.fs +++ b/src/Shared/Shared.fs @@ -1,5 +1,7 @@ namespace ServerCore.Domain +open System + #if FABLE_COMPILER open Thoth.Json #else @@ -113,6 +115,7 @@ type Tag = { Token : string Object : string Description : string + LastVerified : DateTimeOffset Action : TagAction } static member Encoder (tag : Tag) = @@ -120,6 +123,7 @@ type Tag = "Token", Encode.string tag.Token "Description", Encode.string tag.Description "Object", Encode.string tag.Object + "LastVerified", Encode.datetimeOffset tag.LastVerified "Action", TagAction.Encoder tag.Action ] @@ -128,6 +132,9 @@ type Tag = { Token = get.Required.Field "Token" Decode.string Object = get.Required.Field "Object" Decode.string Description = get.Required.Field "Description" Decode.string + LastVerified = + get.Optional.Field "LastVerified" Decode.datetimeOffset + |> Option.defaultValue DateTimeOffset.MinValue Action = get.Required.Field "Action" TagAction.Decoder } )