summaryrefslogtreecommitdiff
path: root/Presence/Stanza/Build.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Presence/Stanza/Build.hs')
-rw-r--r--Presence/Stanza/Build.hs22
1 files changed, 16 insertions, 6 deletions
diff --git a/Presence/Stanza/Build.hs b/Presence/Stanza/Build.hs
index e02684f5..16552428 100644
--- a/Presence/Stanza/Build.hs
+++ b/Presence/Stanza/Build.hs
@@ -19,24 +19,34 @@ import LockedChan
19import Stanza.Types 19import Stanza.Types
20 20
21makeMessage :: Text -> Text -> Text -> Text -> IO Stanza 21makeMessage :: Text -> Text -> Text -> Text -> IO Stanza
22makeMessage namespace from to bod = 22makeMessage namespace from to bod = makeMessageEx namespace from to NormalMsg bod
23
24makeMessageEx :: Text -> Text -> Text -> MessageType -> Text -> IO Stanza
25makeMessageEx namespace from to msgtyp bod =
23 stanzaFromList typ 26 stanzaFromList typ
24 $ [ EventBeginElement (mkname namespace "message") 27 $ [ EventBeginElement (mkname namespace "message")
25 [ attr "from" from 28 $ addMessageType msgtyp
26 , attr "to" to 29 [ attr "from" from
27 ] 30 , attr "to" to
31 ]
28 , EventBeginElement (mkname namespace "body") [] 32 , EventBeginElement (mkname namespace "body") []
29 , EventContent (ContentText bod) 33 , EventContent (ContentText bod)
30 , EventEndElement (mkname namespace "body") 34 , EventEndElement (mkname namespace "body")
31 , EventEndElement (mkname namespace "message") ] 35 , EventEndElement (mkname namespace "message") ]
32 where 36 where
33 typ = Message { msgThread = Nothing 37 typ = Message { msgThread = Nothing
34 , msgLangMap = [("", lsm)] 38 , msgLangMap = [("", lsm)]
39 , msgType = msgtyp
35 } 40 }
36 lsm = LangSpecificMessage 41 lsm = LangSpecificMessage
37 { msgBody = Just bod 42 { msgBody = Just bod
38 , msgSubject = Nothing } 43 , msgSubject = Nothing }
39 44
45addMessageType ChatMsg attrs = ("type",[ContentText "chat"]) : attrs
46addMessageType GroupChatMsg attrs = ("type",[ContentText "groupchat"]) : attrs
47addMessageType HeadlineMsg attrs = ("type",[ContentText "headline"]) : attrs
48addMessageType _ attrs = attrs
49
40makeInformSubscription :: Text -> Text -> Text -> Bool -> IO Stanza 50makeInformSubscription :: Text -> Text -> Text -> Bool -> IO Stanza
41makeInformSubscription namespace from to approved = 51makeInformSubscription namespace from to approved =
42 stanzaFromList (PresenceInformSubscription approved) 52 stanzaFromList (PresenceInformSubscription approved)