Skip to content

Commit

Permalink
update User model
Browse files Browse the repository at this point in the history
  • Loading branch information
yurizhuk committed Nov 29, 2023
1 parent f64ed37 commit 9ed5f14
Show file tree
Hide file tree
Showing 61 changed files with 78 additions and 25 deletions.
2 changes: 1 addition & 1 deletion mobile-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ afterEvaluate {

groupId = "com.webitel"
artifactId = "mobile-sdk"
version = "0.2.61"
version = "0.3.2"
}
}
}
Expand Down
Binary file modified mobile-sdk/build/intermediates/aar_main_jar/release/classes.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#Sun Nov 26 16:01:17 EET 2023
#Wed Nov 29 11:47:24 EET 2023
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
��
�������پ
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
q
r����
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified mobile-sdk/build/tmp/.cache/expanded/expanded.lock
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ internal class AuthRepository(
.setIss(user.iss)
.setSub(user.sub)
.setName(user.name)
.setEmail(user.email)
.setEmailVerified(user.emailVerified)
.setPhoneNumber(user.phoneNumber)
.setPhoneNumberVerified(user.phoneNumberVerified)
.setLocale(user.locale)
.build()

authApi.login(appToken, identity, object : CallbackListener<LoginResponse> {
Expand Down Expand Up @@ -178,7 +183,14 @@ internal class AuthRepository(
iss = s.user.identity.iss,
sub = s.user.identity.sub,
name = s.user.identity.name
).build()
)
.email(s.user.identity.email)
.emailVerified(s.user.identity.emailVerified)
.phoneNumber(s.user.identity.phoneNumber)
.phoneNumberVerified(s.user.identity.phoneNumberVerified)
.locale(s.user.identity.locale)
.build()

request as CallbackListener<UserSession>
request.onSuccess(
UserSession(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ internal class WebitelVoice(
}


private fun getFirstCall():Call? {
return CallsRepository
.activeCalls
.values
.firstOrNull()
}


private fun hasRecordAudioPermission(context: Context): Boolean {
val recordAudio =
ContextCompat.checkSelfPermission(context, Manifest.permission.RECORD_AUDIO)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.webitel.mobile_sdk.data.calls.sip

class CallSettings {
internal class CallSettings {
constructor()

constructor (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ internal class WebitelChat(
val m = getMessageFromOptions(reqId, message)

callback.onSend(m)
dialog.lastMessage = m
//dialog.lastMessage = m

val p = PeerOuterClass.Peer.newBuilder()
.setId(dialog.id)
Expand Down Expand Up @@ -301,10 +301,11 @@ internal class WebitelChat(
if (dispo == Messages.Disposition.Incoming) {
dialog.onReceiveNewMessage(message)
} else if (dispo == Messages.Disposition.Outgoing) {
val lastMessage = dialog.lastMessage
if (lastMessage == null || (lastMessage.id > 0L && message.id > lastMessage.id))
dialog.onReceiveNewMessage(message)
// val lastMessage = dialog.lastMessage
// if (lastMessage == null || (message.id > lastMessage.id))
// dialog.onReceiveNewMessage(message)
}
setTopMessage(dialog, message)
}


Expand Down Expand Up @@ -444,6 +445,7 @@ internal class WebitelChat(
type = "chat",
inbox = chat.inbox,
leftAt = chat.left,
join = chat.join,
lastMessage = message
)
newListDialogs.add(nd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal class WebitelDialog(
val type: String,
var inbox: Int,
var leftAt: Long,
var join: Long,
var lastMessage: Message? = null
) : Dialog {

Expand All @@ -31,13 +32,13 @@ internal class WebitelDialog(


override fun getUpdates(request: HistoryRequest, callback: CallbackListener<List<Message>>) {
val o = request.offset ?: lastMessage?.id ?: 0
apiDelegate.getUpdates(this, o , request.limit, callback)
val offset = request.offset ?: lastMessage?.id ?: join
apiDelegate.getUpdates(this, offset, request.limit, callback)
}


override fun getUpdates(callback: CallbackListener<List<Message>>) {
apiDelegate.getUpdates(this, lastMessage?.id ?: 0, 50, callback)
apiDelegate.getUpdates(this, lastMessage?.id ?: join, 50, callback)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,14 @@ internal class ClientGrpc(
iss = value.user.identity.iss,
sub = value.user.identity.sub,
name = value.user.identity.name
).build()
)
.email(value.user.identity.email)
.emailVerified(value.user.identity.emailVerified)
.phoneNumber(value.user.identity.phoneNumber)
.phoneNumberVerified(value.user.identity.phoneNumberVerified)
.locale(value.user.identity.locale)
.build()

return UserSession(
user = user,
isChatAvailable = value.scopeList.contains("chat"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.util.Objects


@Throws(InvalidProtocolBufferException::class)
fun <T : MessageLite> Any.unpack(clazz: Class<T>): T? {
internal fun <T : MessageLite> Any.unpack(clazz: Class<T>): T? {
val defaultInstance = Internal.getDefaultInstance(clazz)
return try {
@Suppress("UNCHECKED_CAST")
Expand All @@ -19,7 +19,7 @@ fun <T : MessageLite> Any.unpack(clazz: Class<T>): T? {
}


fun <T : MessageLite> Any.Builder.pack(message: T): Any {
internal fun <T : MessageLite> Any.Builder.pack(message: T): Any {
val packageName =
Objects.requireNonNull(message.javaClass.getPackage()).name
return this.setTypeUrl("type.googleapis.com/$packageName." + message.javaClass.simpleName)
Expand All @@ -28,7 +28,7 @@ fun <T : MessageLite> Any.Builder.pack(message: T): Any {
}


fun <T : MessageLite> Any.`is`(clazz: Class<T>): Boolean {
internal fun <T : MessageLite> Any.`is`(clazz: Class<T>): Boolean {
val packageName =
Objects.requireNonNull(clazz.getPackage()).name
return this.typeUrl == "type.googleapis.com/$packageName.${clazz.simpleName}"
Expand Down
39 changes: 39 additions & 0 deletions mobile-sdk/src/main/java/com/webitel/mobile_sdk/domain/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ class User private constructor(builder: Builder) {
val iss: String
val sub: String
val name: String
val email: String
val emailVerified: Boolean
val phoneNumber: String
val phoneNumberVerified: Boolean
var locale: String

init {
iss = builder.iss
sub = builder.sub
name = builder.name
email = builder.email
emailVerified = builder.emailVerified
phoneNumber = builder.phoneNumber
phoneNumberVerified = builder.phoneNumberVerified
locale = builder.locale
}


Expand All @@ -37,6 +47,35 @@ class User private constructor(builder: Builder) {
* */
val name: String
) {
var email: String = ""
private set
var emailVerified: Boolean = false
private set

var phoneNumber: String = ""
private set
var phoneNumberVerified: Boolean = false
private set

var locale: String = ""
private set

fun email(value: String) = apply { this.email = value }

fun emailVerified(value: Boolean) = apply { this.emailVerified = value }

fun phoneNumber(value: String) = apply { this.phoneNumber = value }

fun phoneNumberVerified(value: Boolean) = apply { this.phoneNumberVerified = value }

/**
* End-User's locale, represented as a BCP47 [RFC5646] language tag.
* This is typically an ISO 639-1 Alpha-2 [ISO639‑1] language code in lowercase
* and an ISO 3166-1 Alpha-2 [ISO3166‑1] country code in uppercase,
* separated by a dash. For example, `en-US` or `uk-UA`.
*/
fun locale(value: String) = apply { this.locale = value }

fun build() = User(this)
}
}

0 comments on commit 9ed5f14

Please sign in to comment.