Skip to content
Snippets Groups Projects
Commit 6981db7e authored by Taras's avatar Taras
Browse files

Add propagate param to profile update api

parent c7dfd6d4
No related branches found
No related tags found
No related merge requests found
......@@ -258,7 +258,7 @@ publishing {
release(MavenPublication) {
groupId = "org.futo.gitlab.circles"
artifactId = "matrix-android-sdk"
version = "1.6.10.38"
version = "0.1.61"
afterEvaluate {
from components.release
......
......@@ -46,16 +46,18 @@ interface ProfileService {
* Update the display name for this user.
* @param userId the userId to update the display name of
* @param newDisplayName the new display name of the user
* Changed for Circles - propagateUpdate
*/
suspend fun setDisplayName(userId: String, newDisplayName: String)
suspend fun setDisplayName(userId: String, newDisplayName: String, propagateUpdate: Boolean)
/**
* Update the avatar for this user.
* @param userId the userId to update the avatar of
* @param newAvatarUri the new avatar uri of the user
* @param fileName the fileName of selected image
* Changed for Circles - propagateUpdate
*/
suspend fun updateAvatar(userId: String, newAvatarUri: Uri, fileName: String)
suspend fun updateAvatar(userId: String, newAvatarUri: Uri, fileName: String, propagateUpdate: Boolean)
/**
* Return the current avatarUrl for this user.
......
......@@ -62,16 +62,20 @@ internal class DefaultProfileService @Inject constructor(
return Optional.from(displayName)
}
override suspend fun setDisplayName(userId: String, newDisplayName: String) {
override suspend fun setDisplayName(userId: String, newDisplayName: String, propagateUpdate: Boolean) {
withContext(coroutineDispatchers.io) {
setDisplayNameTask.execute(SetDisplayNameTask.Params(userId = userId, newDisplayName = newDisplayName))
setDisplayNameTask.execute(SetDisplayNameTask.Params(
userId = userId, newDisplayName = newDisplayName, propagateUpdate = propagateUpdate
))
userStore.updateDisplayName(userId, newDisplayName)
}
}
override suspend fun updateAvatar(userId: String, newAvatarUri: Uri, fileName: String) {
override suspend fun updateAvatar(userId: String, newAvatarUri: Uri, fileName: String, propagateUpdate: Boolean) {
val response = fileUploader.uploadFromUri(newAvatarUri, fileName, MimeTypes.Jpeg)
setAvatarUrlTask.execute(SetAvatarUrlTask.Params(userId = userId, newAvatarUrl = response.contentUri))
setAvatarUrlTask.execute(SetAvatarUrlTask.Params(
userId = userId, newAvatarUrl = response.contentUri, propagateUpdate = propagateUpdate
))
userStore.updateAvatar(userId, response.contentUri)
}
......
......@@ -26,6 +26,7 @@ import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query
import retrofit2.http.Url
internal interface ProfileAPI {
......@@ -51,6 +52,7 @@ internal interface ProfileAPI {
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}/displayname")
suspend fun setDisplayName(
@Path("userId") userId: String,
@Query("org.matrix.msc4069.propagate") propagate: Boolean,
@Body body: SetDisplayNameBody
)
......@@ -60,6 +62,7 @@ internal interface ProfileAPI {
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}/avatar_url")
suspend fun setAvatarUrl(
@Path("userId") userId: String,
@Query("org.matrix.msc4069.propagate") propagate: Boolean,
@Body body: SetAvatarUrlBody
)
......
......@@ -24,7 +24,8 @@ import javax.inject.Inject
internal abstract class SetAvatarUrlTask : Task<SetAvatarUrlTask.Params, Unit> {
data class Params(
val userId: String,
val newAvatarUrl: String
val newAvatarUrl: String,
val propagateUpdate: Boolean
)
}
......@@ -38,7 +39,7 @@ internal class DefaultSetAvatarUrlTask @Inject constructor(
avatarUrl = params.newAvatarUrl
)
return executeRequest(globalErrorReceiver) {
profileAPI.setAvatarUrl(params.userId, body)
profileAPI.setAvatarUrl(params.userId, params.propagateUpdate, body)
}
}
}
......@@ -24,7 +24,8 @@ import javax.inject.Inject
internal abstract class SetDisplayNameTask : Task<SetDisplayNameTask.Params, Unit> {
data class Params(
val userId: String,
val newDisplayName: String
val newDisplayName: String,
val propagateUpdate: Boolean
)
}
......@@ -38,7 +39,7 @@ internal class DefaultSetDisplayNameTask @Inject constructor(
displayName = params.newDisplayName
)
return executeRequest(globalErrorReceiver) {
profileAPI.setDisplayName(params.userId, body)
profileAPI.setDisplayName(params.userId, params.propagateUpdate, body)
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment