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

Remove "X kicked X" terminology when removing people from a room #4911

Merged
merged 4 commits into from
Jan 14, 2022

Conversation

fedrunov
Copy link
Contributor

there are three separate commits:

  1. replacing "kick" with "remove" in code and resource. String reource's keys are unaffected, @bmarty said that will handle it later
  2. adding alias to commands.
  3. adding aliases which are already exist in web app, taking from https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/SlashCommands.tsx

also there are some small fixes/changes:

  • case is now ignored (before /Nick returned an error, now works)
  • fixed typo ("sPlashCommand") in method name and logs (could change in logs somehow affect analytics?)
  • added strict check for excess params for DISCARD_SESSION command, same as it is for CLEAR_SCALAR_TOKEN
  • some commands didn't require param, while it looks like they should, so check was addde:
    /rainbow - posts empty message
    /spoiler - posts empty message
    /me - posts message with just user name
    /rainbowme - posts message with just user name

fixes #4865

@fedrunov fedrunov requested a review from bmarty January 11, 2022 15:59
@github-actions
Copy link

github-actions bot commented Jan 11, 2022

Unit Test Results

  66 files  ±0    66 suites  ±0   49s ⏱️ -4s
135 tests ±0  135 ✔️ ±0  0 💤 ±0  0 ±0 
418 runs  ±0  418 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit d92e0e4. ± Comparison against base commit 67bdf4b.

♻️ This comment has been updated with latest results.

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Not a lot to say, this is really nice work, thanks!

@@ -77,7 +77,7 @@ interface MembershipService {
/**
* Kick a user from the room
*/
suspend fun kick(userId: String, reason: String? = null)
suspend fun remove(userId: String, reason: String? = null)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe also update the comment above

@@ -77,7 +77,7 @@ interface MembershipService {
/**
* Kick a user from the room
*/
suspend fun kick(userId: String, reason: String? = null)
suspend fun remove(userId: String, reason: String? = null)
Copy link
Member

Choose a reason for hiding this comment

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

As it is a change in the SDK api, would be better to keep kick as an alias to remove and mark it as deprecated.
You can write in the interface something like:

@Deprecated("Use remove now")
suspend fun kick(userId: String, reason: String? = null) = remove(userId, reason)

JOIN_SPACE("/joinSpace", "spaceId", R.string.command_description_join_space, true),
LEAVE_ROOM("/leave", "<roomId?>", R.string.command_description_leave_room, true),
UPGRADE_ROOM("/upgraderoom", "newVersion", R.string.command_description_upgrade_room, true);
enum class Command(val command: String, val aliases: Array<CharSequence>?, val parameters: String, @StringRes val description: Int, val isDevCommand: Boolean) {
Copy link
Member

Choose a reason for hiding this comment

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

not a strong opinion about it, but why using Array instead of List?

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 did it because of spread operation used later here

val allAliases = arrayOf(command, *aliases.orEmpty())

@@ -32,12 +32,12 @@ object CommandParser {
* @param textMessage the text message
* @return a parsed slash command (ok or error)
*/
fun parseSplashCommand(textMessage: CharSequence): ParsedCommand {
fun parseSlashCommand(textMessage: CharSequence): ParsedCommand {
Copy link
Member

Choose a reason for hiding this comment

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

Good catch, nice typo, thanks :)

Copy link
Member

Choose a reason for hiding this comment

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

(my bad eae8f99 :) )

// check if it has the Slash marker
if (!textMessage.startsWith("/")) {
return ParsedCommand.ErrorNotACommand
} else {
Timber.v("parseSplashCommand")
Timber.v("parseSlashCommand")
Copy link
Member

Choose a reason for hiding this comment

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

Changing the logs does not impact analytics.

if (newVersion.isEmpty()) {
ParsedCommand.ErrorSyntax(Command.UPGRADE_ROOM)
Command.ADD_TO_SPACE.matches(slashCommand) -> {
ParsedCommand.AddToSpace(spaceId = message)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we miss some validation of message for this command and the one below.


private fun trimParts(message: CharSequence, messageParts: List<String>): String? {
val partsSize = messageParts.sumOf { it.length }
val gapsNumber = messageParts.size - 1
Copy link
Member

Choose a reason for hiding this comment

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

I am wondering if it still works well if the user adds more space chars between the params

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've checked this case and it worked well. It just trims every space betwen params

@@ -25,8 +25,8 @@
<string name="notice_direct_room_leave_by_you">You left the room</string>
<string name="notice_room_reject">%1$s rejected the invitation</string>
<string name="notice_room_reject_by_you">You rejected the invitation</string>
<string name="notice_room_kick">%1$s kicked %2$s</string>
<string name="notice_room_kick_by_you">You kicked %1$s</string>
<string name="notice_room_kick">%1$s removed %2$s</string>
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a TODO in XML comment above so that I will not forget to rename during the next weblate sync. Thanks. (only one comment will be enough)

@@ -0,0 +1 @@
"/kick" command is replaced with "/remove"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe also mention the replacement in the wordings.

@github-actions
Copy link

Matrix SDK

Integration Tests Results:

  • [org.matrix.android.sdk.session]
    passed="21" failures="0" errors="0" skipped="2"
  • [org.matrix.android.sdk.account]
    passed="5" failures="0" errors="0" skipped="2"
  • [org.matrix.android.sdk.internal]
    passed="1" failures="1" errors="0" skipped="0"
  • [org.matrix.android.sdk.ordering]
    passed="1" failures="1" errors="0" skipped="0"
  • [org.matrix.android.sdk.PermalinkParserTest]
    passed="1" failures="1" errors="0" skipped="0"

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks for the update!

@bmarty bmarty merged commit 31e487b into develop Jan 14, 2022
@bmarty bmarty deleted the feature/nfe/rename_kick_command branch January 14, 2022 07:42
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.

Remove "X kicked X" terminology when removing people from a room
2 participants