-
Notifications
You must be signed in to change notification settings - Fork 744
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
Fix Sending Stickers from Dimension doesn't work #4984
Conversation
Fix a saclar token is needed by self deployed dimension when using sticker picker Fix roomid check is no needed when using sticker picker Noted: there still problem to enable sticker picker for the first time, if we want to use sticker picker, we should enable it on element-web then we can use sticker picker in android with self deployed dimension
@@ -211,12 +212,23 @@ class WidgetPostAPIHandler @AssistedInject constructor(@Assisted private val roo | |||
* @param eventData the modular data | |||
*/ | |||
private fun getWidgets(widgetPostAPIMediator: WidgetPostAPIMediator, eventData: JsonDict) { | |||
if (checkRoomId(widgetPostAPIMediator, eventData)) { | |||
return | |||
//if (checkRoomId(widgetPostAPIMediator, eventData)) { |
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.
if it's no longer needed lets delete the code rather than commenting out ♻️
//if (checkRoomId(widgetPostAPIMediator, eventData)) { | ||
// return | ||
//} | ||
val roomIdInEvent = eventData["room_id"] as String? |
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.
I'm wondering if this could be simplified to
val allWidgets = when {
eventData.isMissingRoomId() -> session.widgetService().getUserWidgets()
roomId == eventData.roomId -> session.widgetService().getRoomWidgets(roomId) + session.widgetService().getUserWidgets()
else -> {
widgetPostAPIMediator.sendError(stringProvider.getString(R.string.widget_integration_room_not_visible), eventData)
return
}
}
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.
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.
ah my bad! this was a mix of pseudo code, these could be implemented as kotlin extension functions on the JsonDict
, we could also extract another for matching against the room id
private fun getWidgets(widgetPostAPIMediator: WidgetPostAPIMediator, eventData: JsonDict) {
val allWidgets = when {
eventData.isMissingRoomId() -> session.widgetService().getUserWidgets()
eventData.hasMatchingRoom(roomId) -> session.widgetService().getRoomWidgets(roomId) + session.widgetService().getUserWidgets()
else -> {
widgetPostAPIMediator.sendError(stringProvider.getString(R.string.widget_integration_room_not_visible), eventData)
return
}
}
...
}
private fun JsonDict.isMissingRoomId() = (this["room_id"] as? String).isNullOrEmpty()
private fun JsonDict.hasMatchingRoom(roomId: String) = (this["room_id"] as? String) == roomId
as code view suggest, try to simplify the code
delete repeat debug message
OK, I have made a small mistake when fixing the conflict, the code will not compile. Can you add a sign-off to the PR, so that I can merge it to one of my branch to be able to fix the issue? Thanks @acheng-floyd |
Stale PR, feel free to update and re-open. |
Fixes: Sending Stickers from Dimension doesn't work #1497
A saclar token is needed by self deployed dimension when using sticker picker.
Fix roomid check is no needed when using sticker picker
Noted: there still problem to enable sticker picker for the first time, if we want to use sticker picker, we should enable it on element-web then we can use sticker picker in android with self deployed dimension
Here's what your changelog entry will look like:
🐛 Bug Fixes
Fixes: Sending Stickers from Dimension doesn't work #1497. Contributed by @achengfloyd
Before fix:
After fix: