Skip to content
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

Merged

Conversation

yafred
Copy link
Contributor

@yafred yafred commented Jan 13, 2025

Another idea to fix #16715 (follow-up on #16761)

Chat json data is stripped for kids to only keep what is needed to write notes.
The UI part makes sure the chat tabs (room and palantir) are not displayed and no communication with redis is happening.

@yafred yafred marked this pull request as ready for review January 13, 2025 22:19
"name" -> name,
"lines" -> lines,
"resourceId" -> resourceId.value
"data" -> false
Copy link
Collaborator

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

data: ChatData;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done
I put the mandatory fields only with 'sensible' content

Example:
"chat":{"data":{"id":"","name":"","lines":[],"resourceId":"","loginRequired":true,"restricted":true},"kidMode":true,"noteId":"YHW3eKqs","noteAge":256381}

)
if ctx.kid.yes then
Json
.obj("data" -> false)
Copy link
Collaborator

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

data: ChatData;

Json
.obj("data" -> false)
.add("kidMode" -> true)
.add("noteId" -> (withNoteAge.isDefined && ctx.noBlind).option(chat.id.value.take(8)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code duplication with line 99

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

.add("timeout" -> (public && Granter.opt(_.ChatTimeout)))
.add("shadowban" -> (public && Granter.opt(_.Shadowban)))
)
.add("kidMode" -> ctx.kid.yes)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be omitted since we know that ctx.kid.no

Copy link
Contributor Author

@yafred yafred Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done
I am not sure how it works though
absent means false (on the typescript side) ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lila usually omits false or missing values altogether.

"data" -> Json
.obj(
"id" -> "",
"name" -> "",
Copy link
Collaborator

@ornicar ornicar Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is not good. If the ts typing says that there exists data.id: string and data.name: string, and you pass them empty strings, then you just made typing useless. Worse, the typing now gives a false sense of security.

I don't want our TS code to check if every string is empty before use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may have misunderstood your point in the first place.
Hopefully this fix will be what you had in mind
Thanks for your patience and your feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see some errors in the console when playing with the notes.
But it's also happening on master.

{"SyntaxError":"JSON.parse: unexpected end of data at line 1 column 1 of the JSON data","stack":""}

@ornicar ornicar merged commit f528bb9 into lichess-org:master Jan 21, 2025
5 checks passed
@yafred yafred deleted the issue-16715-notes-in-kid-mode-take2 branch January 21, 2025 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

private game/player notes in kidmode (regression)
2 participants