-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into aa/fix/calculate-storage-percentage
- Loading branch information
Showing
46 changed files
with
544 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...pers/wrapper-common/src/main/java/chat/sphinx/wrapper_common/chat/PushNotificationLink.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package chat.sphinx.wrapper_common.chat | ||
|
||
@Suppress("NOTHING_TO_INLINE") | ||
inline fun String.toPushNotificationLink(): PushNotificationLink? = | ||
try { | ||
PushNotificationLink(this) | ||
} catch (e: IllegalArgumentException) { | ||
null | ||
} | ||
|
||
inline val String.isValidPushNotificationLink: Boolean | ||
get() = isNotEmpty() && matches("^${PushNotificationLink.REGEX}\$".toRegex()) | ||
|
||
@JvmInline | ||
value class PushNotificationLink(val value: String) { | ||
|
||
companion object { | ||
const val REGEX = "sphinx\\.chat:\\/\\/\\?action=push&chatId=.*" | ||
const val CHAT_ID = "chatId" | ||
} | ||
|
||
init { | ||
require(value.isValidPushNotificationLink) { | ||
"Invalid Push Notification Link" | ||
} | ||
} | ||
|
||
inline val chatId : Long? | ||
get() = (getComponent(CHAT_ID) ?: "").trim().toLongOrNull() | ||
|
||
fun getComponent(k: String): String? { | ||
val components = value.replace("sphinx.chat://", "").split("&") | ||
for (component in components) { | ||
val subComponents = component.split("=") | ||
val key:String? = if (subComponents.isNotEmpty()) subComponents.elementAtOrNull(0) else null | ||
val value:String? = if (subComponents.size > 1) subComponents.elementAtOrNull(1) else null | ||
|
||
if (key == k) return value | ||
} | ||
return null | ||
} | ||
|
||
} |
Oops, something went wrong.