Merge pull request #2749 from vector-im/feature/ons/fix_replace_matrix_widget_id
Support $matrix_widget_id parameter.
This commit is contained in:
commit
98054815a4
@ -13,6 +13,7 @@ Bugfix 🐛:
|
||||
- UrlPreview should be updated when the url is edited and changed (#2678)
|
||||
- When receiving a new pepper from identity server, use it on the next hash lookup (#2708)
|
||||
- Crashes reported by PlayStore (new in 1.0.14) (#2707)
|
||||
- Widgets: Support $matrix_widget_id parameter (#2748)
|
||||
|
||||
Translations 🗣:
|
||||
-
|
||||
|
@ -53,7 +53,7 @@ internal class WidgetFactory @Inject constructor(private val userDataSource: Use
|
||||
}
|
||||
}
|
||||
val isAddedByMe = widgetEvent.senderId == userId
|
||||
val computedUrl = widgetContent.computeURL(widgetEvent.roomId)
|
||||
val computedUrl = widgetContent.computeURL(widgetEvent.roomId, widgetId)
|
||||
return Widget(
|
||||
widgetContent = widgetContent,
|
||||
event = widgetEvent,
|
||||
@ -65,13 +65,14 @@ internal class WidgetFactory @Inject constructor(private val userDataSource: Use
|
||||
)
|
||||
}
|
||||
|
||||
private fun WidgetContent.computeURL(roomId: String?): String? {
|
||||
private fun WidgetContent.computeURL(roomId: String?, widgetId: String): String? {
|
||||
var computedUrl = url ?: return null
|
||||
val myUser = userDataSource.getUser(userId)
|
||||
computedUrl = computedUrl
|
||||
.replace("\$matrix_user_id", userId)
|
||||
.replace("\$matrix_display_name", myUser?.displayName ?: userId)
|
||||
.replace("\$matrix_avatar_url", myUser?.avatarUrl ?: "")
|
||||
.replace("\$matrix_widget_id", widgetId)
|
||||
|
||||
if (roomId != null) {
|
||||
computedUrl = computedUrl.replace("\$matrix_room_id", roomId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user