Skip to content

Commit

Permalink
(#102) LinkGenerator: migrate to async
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Oct 3, 2021
1 parent 4816be7 commit 1177910
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Emulsion.Tests/Telegram/FunogramTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ let private forwardingUser = createUser (Some "forwardingUser") "" None

module ReadMessageTests =
let private readMessage m =
let links = LinkGenerator.gatherLinks m
let links = Async.RunSynchronously(LinkGenerator.gatherLinks m)
MessageConverter.read selfUserId (m, links)

[<Fact>]
Expand Down
2 changes: 1 addition & 1 deletion Emulsion/Telegram/Funogram.fs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ let internal processSendResult(result: Result<'a, ApiResponseError>): unit =
failwith $"Telegram API Call processing error {e.ErrorCode}: {e.Description}"

let private extractLinkData message =
message, gatherLinks message
message, Async.RunSynchronously(gatherLinks message)

let internal processMessage (context: {| SelfUserId: int64; GroupId: int64 |})
(message: FunogramMessage): Message option =
Expand Down
8 changes: 5 additions & 3 deletions Emulsion/Telegram/LinkGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ let private gatherMessageLink(message: FunogramMessage) =
| { Text = Some _} | { Poll = Some _ } -> None
| _ -> getMessageLink message

let gatherLinks(message: FunogramMessage): TelegramThreadLinks = {
ContentLink = gatherMessageLink message
ReplyToContentLink = message.ReplyToMessage |> Option.bind gatherMessageLink
let gatherLinks(message: FunogramMessage): Async<TelegramThreadLinks> = async {
return {
ContentLink = gatherMessageLink message
ReplyToContentLink = message.ReplyToMessage |> Option.bind gatherMessageLink
}
}

0 comments on commit 1177910

Please sign in to comment.