Skip to content

Commit

Permalink
More information in discussion callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
achlipala committed Dec 26, 2015
1 parent 22dd291 commit b1d9b4b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 8 deletions.
16 changes: 14 additions & 2 deletions discussion.ur
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ functor Make(M : sig

val showOpenVsClosed : bool
val allowPrivate : bool
val onNewMessage : {thread : time, Subject : string, Who : string, Text : string} -> transaction unit
val onNewMessage : transaction (list string)
-> {thread : time, Subject : string, Who : string, Text : string}
-> transaction unit
end) = struct

open M
Expand Down Expand Up @@ -368,7 +370,17 @@ functor Make(M : sig
broadcast (fn ch => send ch (New {Thread = thread, When = tm, Who = u, Text = text}))
k row.Private row.Who;

onNewMessage {thread = thread, Subject = row.Text, Who = u, Text = text}
onNewMessage
(List.mapQuery (SELECT DISTINCT message.Who
FROM message
WHERE {@@Sql.easy_where [#Message] [key ++ [thread = _]]
[[When = _, Who = _, Text = _]]
[[]] [[]] [[]] ! !
(kinj ++ {thread = _})
(@Folder.concat ! _ fl)
(k ++ {thread = thread})})
(fn {Message = {Who = w}} => w))
{thread = thread, Subject = row.Text, Who = u, Text = text}

fun saveMsg k thread msg text =
acc <- access k;
Expand Down
5 changes: 4 additions & 1 deletion discussion.urs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ functor Make(M : sig
val allowPrivate : bool
(* May users create threads visible only to themselves and admins? *)

val onNewMessage : {thread : time, Subject : string, Who : string, Text : string} -> transaction unit
val onNewMessage : transaction (list string)
(* Run to get list of all users who have posted in the thread. *)
-> {thread : time, Subject : string, Who : string, Text : string}
-> transaction unit
(* Callback for every new message posted in any thread *)
end) : sig
include Ui.S where type input = $M.key
Expand Down
4 changes: 3 additions & 1 deletion globalDiscussion.ur
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ functor Make(M : sig
val access : transaction Discussion.access
val showOpenVsClosed : bool
val allowPrivate : bool
val onNewMessage : {Thread : time, Subject : string, Who : string, Text : string} -> transaction unit
val onNewMessage : transaction (list string)
-> {Thread : time, Subject : string, Who : string, Text : string}
-> transaction unit
end) = struct

open M
Expand Down
4 changes: 3 additions & 1 deletion globalDiscussion.urs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ functor Make(M : sig
val access : transaction Discussion.access
val showOpenVsClosed : bool
val allowPrivate : bool
val onNewMessage : {Thread : time, Subject : string, Who : string, Text : string} -> transaction unit
val onNewMessage : transaction (list string)
-> {Thread : time, Subject : string, Who : string, Text : string}
-> transaction unit
end) : sig
include Ui.S0

Expand Down
1 change: 0 additions & 1 deletion submission.ur
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ functor Make(M : sig
val keyInj' = @mp [sql_injectable_prim] [sql_injectable] @@sql_prim keyFl keyInj

table listeners : (key ++ [ukey = option string, Channel = channel {Filename : option string, When : time, ukey : string}])
{{one_constraint [#Key] (@Sql.easy_foreign ! ! ! ! ! ! keyFl tab)}}

fun upload k h vs =
cl <- AjaxUpload.claim h;
Expand Down
4 changes: 3 additions & 1 deletion tableDiscussion.ur
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ functor Make(M : sig
val access : $key -> transaction Discussion.access
val showOpenVsClosed : bool
val allowPrivate : bool
val onNewMessage : {thread : time, Subject : string, Who : string, Text : string} -> transaction unit
val onNewMessage : transaction (list string)
-> {thread : time, Subject : string, Who : string, Text : string}
-> transaction unit
end) = struct

open M
Expand Down
4 changes: 3 additions & 1 deletion tableDiscussion.urs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ functor Make(M : sig
val access : $key -> transaction Discussion.access
val showOpenVsClosed : bool
val allowPrivate : bool
val onNewMessage : {thread : time, Subject : string, Who : string, Text : string} -> transaction unit
val onNewMessage : transaction (list string)
-> {thread : time, Subject : string, Who : string, Text : string}
-> transaction unit
end) : sig
include Ui.S where type input = $M.key

Expand Down

0 comments on commit b1d9b4b

Please sign in to comment.