-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow private notes on games in kid mode #16769
Changes from 3 commits
78986a4
be97e44
7b5f24f
f9d0253
ea8aec2
8b30069
6069871
35c1e91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,34 +64,42 @@ final class ChatUi(helpers: Helpers): | |
palantir: Boolean = false, | ||
hostIds: List[UserId] = Nil | ||
)(using ctx: Context): JsObject = | ||
Json | ||
.obj( | ||
"data" -> Json | ||
.obj( | ||
"id" -> chat.id, | ||
"name" -> name, | ||
"lines" -> lines, | ||
"resourceId" -> resourceId.value | ||
) | ||
.add("hostIds" -> hostIds.some.filter(_.nonEmpty)) | ||
.add("userId" -> ctx.userId) | ||
.add("loginRequired" -> chat.loginRequired) | ||
.add("restricted" -> restricted) | ||
.add("palantir" -> (palantir && ctx.isAuth)), | ||
"writeable" -> writeable, | ||
"public" -> public, | ||
"permissions" -> Json | ||
.obj("local" -> (public && localMod)) | ||
.add("broadcast" -> (public && broadcastMod)) | ||
.add("timeout" -> (public && Granter.opt(_.ChatTimeout))) | ||
.add("shadowban" -> (public && Granter.opt(_.Shadowban))) | ||
) | ||
.add("kobold" -> ctx.troll) | ||
.add("blind" -> ctx.blind) | ||
.add("timeout" -> timeout) | ||
.add("noteId" -> (withNoteAge.isDefined && ctx.noBlind).option(chat.id.value.take(8))) | ||
.add("noteAge" -> withNoteAge) | ||
.add( | ||
"timeoutReasons" -> (!localMod && (Granter.opt(_.ChatTimeout) || Granter.opt(_.BroadcastTimeout))) | ||
.option(JsonView.timeoutReasons) | ||
) | ||
if ctx.kid.yes then | ||
Json | ||
.obj("data" -> false) | ||
.add("kidMode" -> true) | ||
.add("noteId" -> (withNoteAge.isDefined && ctx.noBlind).option(chat.id.value.take(8))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code duplication with line 99 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
.add("noteAge" -> withNoteAge) | ||
else | ||
Json | ||
.obj( | ||
"data" -> Json | ||
.obj( | ||
"id" -> chat.id, | ||
"name" -> name, | ||
"lines" -> lines, | ||
"resourceId" -> resourceId.value | ||
) | ||
.add("hostIds" -> hostIds.some.filter(_.nonEmpty)) | ||
.add("userId" -> ctx.userId) | ||
.add("loginRequired" -> chat.loginRequired) | ||
.add("restricted" -> restricted) | ||
.add("palantir" -> (palantir && ctx.isAuth)), | ||
"writeable" -> writeable, | ||
"public" -> public, | ||
"permissions" -> Json | ||
.obj("local" -> (public && localMod)) | ||
.add("broadcast" -> (public && broadcastMod)) | ||
.add("timeout" -> (public && Granter.opt(_.ChatTimeout))) | ||
.add("shadowban" -> (public && Granter.opt(_.Shadowban))) | ||
) | ||
.add("kidMode" -> ctx.kid.yes) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can be omitted since we know that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lila usually omits false or missing values altogether. |
||
.add("kobold" -> ctx.troll) | ||
.add("blind" -> ctx.blind) | ||
.add("timeout" -> timeout) | ||
.add("noteId" -> (withNoteAge.isDefined && ctx.noBlind).option(chat.id.value.take(8))) | ||
.add("noteAge" -> withNoteAge) | ||
.add( | ||
"timeoutReasons" -> (!localMod && (Granter.opt(_.ChatTimeout) || Granter.opt(_.BroadcastTimeout))) | ||
.option(JsonView.timeoutReasons) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes the TS types lie