Skip to content

Commit

Permalink
Fix the namespace for message body (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Jul 8, 2019
1 parent b009ec8 commit d37e5c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 8 additions & 0 deletions Emulsion.Tests/Xmpp/SharpXmppHelper.fs
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
module Emulsion.Tests.Xmpp.SharpXmppHelper

open System.Xml.Linq

open Xunit

open Emulsion
open Emulsion.Tests.Xmpp
open Emulsion.Xmpp

[<Fact>]
let ``Message body has a proper namespace``() =
let message = SharpXmppHelper.message "cthulhu@test" "text"
let body = Seq.exactlyOne(message.Descendants())
Assert.Equal(XNamespace.Get "jabber:client", body.Name.Namespace)

[<Fact>]
let ``parseMessage should extract message text and author``() =
let text = "text test"
Expand Down
11 changes: 4 additions & 7 deletions Emulsion/Xmpp/SharpXmppHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,22 @@ open SharpXMPP.XMPP.Client.Elements

open Emulsion

module Namespaces =
let StorageBookmarks = XNamespace.Get("storage:bookmarks")

module Elements =
let Body = XName.Get "body"
let Body = XName.Get("body", Namespaces.JabberClient)
let Delay = XName.Get("delay", "urn:xmpp:delay")
let From = XName.Get "from"
let Jid = XName.Get "jid"
let Nick = XName.Get("nick", Namespaces.StorageBookmarks)
let Stamp = XName.Get "stamp"
let Type = XName.Get "type"
let To = XName.Get "to"
let Type = XName.Get "type"

open Namespaces
open Elements

let private bookmark (roomJid: string) (nickname: string): BookmarkedConference =
let room = BookmarkedConference()
room.SetAttributeValue(Jid, roomJid)
let nickElement = XElement(StorageBookmarks + "nick", Value = nickname)
let nickElement = XElement(Nick, Value = nickname)
room.Add(nickElement)
room

Expand Down

0 comments on commit d37e5c8

Please sign in to comment.