summaryrefslogtreecommitdiff
path: root/desk/lib/chat.hoon
diff options
context:
space:
mode:
Diffstat (limited to 'desk/lib/chat.hoon')
-rw-r--r--desk/lib/chat.hoon88
1 files changed, 88 insertions, 0 deletions
diff --git a/desk/lib/chat.hoon b/desk/lib/chat.hoon
new file mode 100644
index 0000000..9390c35
--- /dev/null
+++ b/desk/lib/chat.hoon
@@ -0,0 +1,88 @@
+/- chat
+|%
++$ eyre-id @ta
++$ card card:agent:gall
+:: cards
+++ watch-chat
+ |= [our=ship =term]
+ ^- card
+ :* %pass
+ /listen/[term]
+ %agent
+ [our %chat]
+ %watch
+ /chat/(scot %p our)/[term]/ui/writs
+ ==
+++ leave-chat
+ |= [our=ship =term]
+ ^- card
+ [%pass /listen/[term] %agent [our %chat] %leave ~]
+++ handle-msg
+ |= [=wire =sign:agent:gall]
+ ^- (quip card _this)
+ ?. ?=(%fact -.sign) `this
+ =* mark p.cage.sign
+ =* vase q.cage.sign
+ ?. ?=(%writ-diff p.cage.sign) `this
+ =^ cards state
+ (handle-chat-update:do source !<(diff:writs:chat vase))
+ [cards this]
+ ==
+==
+++ handle-chat-update
+|= =diff:writs:chat ^- (list card)
+:: TODO other stuff
+?. ?=(%add -.q.diff) `this
+(send-to-viewers p.q.diff)
+++ send-to-viewers
+|= =memo:chat
+=/ ids=(set eyre-id) (sy ~['lol'])
+:_ ~
+:* %give
+ %fact
+ ::
+ %+ turn ~(tap in ids)
+ |= =eyre-id
+ /http-response/[eyre-id]
+ ::
+ %http-response-data
+ !> ^- (unit octs)
+ %- some
+ (make-stream-data (scot %uw (jam memo)))
+==
++$ channel-event
+ $% $>(%poke-ack sign:agent:gall)
+ $>(%watch-ack sign:agent:gall)
+ $>(%kick sign:agent:gall)
+ [%fact =desk =mark =noun]
+ ==
+++ channel-event-to-tape
+|= [request-id=@ud =channel-event]
+=+ [request-id channel-event]
+(scow %uw (jam -))
+++ make-stream-data
+ |= =cord
+ ^- octs
+ %- as-octs:mimes:html
+ (rap 3 'data:' cord '\0a\0a' ~)
+
+:: user management
+
+:: ++ ban-comet
+:: |= who=ship
+:: ^- (quip card _state)
+:: :- ~
+:: %_ state
+:: guests (~(del by guests) who)
+:: banned (~(uni in banned) (~(get ju guests) who))
+:: ==
+:: ::
+:: ++ unban-ip
+:: |= =address:eyre
+:: ^- (quip card _state)
+:: :- ~
+:: %_ state
+:: banned (~(del in banned) address.action)
+:: ==
+
+-- \ No newline at end of file