chore: Update project assets and improve documentation
This commit includes various updates to project assets and documentation for better clarity and organization. - Added new drawable resources for the application, including logos and icons. - Introduced new font resources to enhance typography across the app. - Updated `README.md` and `README_APP_LINKS.md` to provide clearer instructions and troubleshooting tips. - Refactored `AndroidManifest.xml` to streamline asset references and ensure proper integration. - Improved localization support by updating multiple `strings.xml` files for various languages. - Removed obsolete drawable resources to reduce clutter and improve maintainability.
This commit is contained in:
parent
a18909476a
commit
664c623aeb
|
|
@ -14,7 +14,7 @@ jobs:
|
|||
run: |
|
||||
gh api graphql -f query='
|
||||
query {
|
||||
organization(login: "revoltchat"){
|
||||
organization(login: "peptidechat"){
|
||||
projectV2(number: 3) {
|
||||
id
|
||||
fields(first:20) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ jobs:
|
|||
run: |
|
||||
gh api graphql -f query='
|
||||
query {
|
||||
organization(login: "revoltchat"){
|
||||
organization(login: "peptidechat"){
|
||||
projectV2(number: 5) {
|
||||
id
|
||||
fields(first:20) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
revoltbuild.properties
|
||||
peptidebuild.properties
|
||||
sentry.properties
|
||||
/.kotlin/sessions
|
||||
app/src/main/assets/embedded
|
||||
|
|
|
|||
22
README.md
22
README.md
|
|
@ -1,9 +1,9 @@
|
|||
# Revolt on Android
|
||||
# Peptide on Android
|
||||
|
||||
## Description
|
||||
|
||||
This is the official Android app for the [Revolt](https://revolt.chat) chat platform.
|
||||
The codebase includes the app itself, as well as an internal library for interacting with the Revolt
|
||||
This is the official Android app for the [Peptide](https://peptide.chat) chat platform.
|
||||
The codebase includes the app itself, as well as an internal library for interacting with the Peptide
|
||||
API.
|
||||
|
||||
| Module | Package | Description |
|
||||
|
|
@ -29,18 +29,18 @@ of the art for Android UI development.
|
|||
|
||||
## Resources
|
||||
|
||||
### Revolt on Android
|
||||
### Peptide on Android
|
||||
|
||||
- [Revolt on Android Technical Documentation](https://revoltchat.github.io/android/)
|
||||
- [Android-specific Contribution Guide](https://revoltchat.github.io/android/contributing/guidelines/)
|
||||
- [Peptide on Android Technical Documentation](https://peptidechat.github.io/android/)
|
||||
- [Android-specific Contribution Guide](https://peptidechat.github.io/android/contributing/guidelines/)
|
||||
—**read carefully before contributing!**
|
||||
|
||||
### Revolt
|
||||
### Peptide
|
||||
|
||||
- [Revolt Project Board](https://github.com/revoltchat/revolt/discussions) (Submit feature requests
|
||||
- [Peptide Project Board](https://github.com/peptidechat/peptide/discussions) (Submit feature requests
|
||||
here)
|
||||
- [Revolt Testers Server](https://app.revolt.chat/invite/Testers)
|
||||
- [General Revolt Contribution Guide](https://developers.revolt.chat/contributing)
|
||||
- [Peptide Testers Server](https://app.peptide.chat/invite/Testers)
|
||||
- [General Peptide Contribution Guide](https://developers.peptide.chat/contributing)
|
||||
|
||||
## Quick Start
|
||||
|
||||
|
|
@ -48,4 +48,4 @@ Open the project in Android Studio. You can then run the app on an emulator or a
|
|||
running the `app` module.
|
||||
|
||||
In-depth setup instructions can be found
|
||||
at [Setting up your Development Environment](https://revoltchat.github.io/android/contributing/setup/)
|
||||
at [Setting up your Development Environment](https://peptidechat.github.io/android/contributing/setup/)
|
||||
|
|
@ -62,9 +62,9 @@ fun property(fileName: String, propertyName: String, fallbackEnv: String? = null
|
|||
}
|
||||
}
|
||||
|
||||
// Calls property but with revoltbuild.properties as the first argument
|
||||
// Calls property but with peptidebuild.properties as the first argument
|
||||
fun buildproperty(propertyName: String, fallbackEnv: String? = null): String? {
|
||||
return property("revoltbuild.properties", propertyName, fallbackEnv)
|
||||
return property("peptidebuild.properties", propertyName, fallbackEnv)
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@
|
|||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:name=".RevoltApplication"
|
||||
android:theme="@style/Theme.Revolt"
|
||||
android:name=".PeptideApplication"
|
||||
android:theme="@style/Theme.Peptide"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
tools:targetApi="tiramisu">
|
||||
<provider
|
||||
|
|
@ -72,7 +72,7 @@
|
|||
android:exported="true"
|
||||
android:configChanges="orientation|screenSize|colorMode"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.Revolt">
|
||||
android:theme="@style/Theme.Peptide">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
|
||||
<activity
|
||||
android:name=".activities.InviteActivity"
|
||||
android:theme="@style/Theme.Revolt"
|
||||
android:theme="@style/Theme.Peptide"
|
||||
android:exported="true">
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
|
@ -118,7 +118,7 @@
|
|||
|
||||
<activity
|
||||
android:name=".activities.ShareTargetActivity"
|
||||
android:theme="@style/Theme.Revolt"
|
||||
android:theme="@style/Theme.Peptide"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
|
|
@ -134,12 +134,12 @@
|
|||
|
||||
<activity
|
||||
android:name=".activities.media.ImageViewActivity"
|
||||
android:theme="@style/Theme.Revolt" />
|
||||
android:theme="@style/Theme.Peptide" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.media.VideoViewActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:theme="@style/Theme.Revolt" />
|
||||
android:theme="@style/Theme.Peptide" />
|
||||
|
||||
<!-- Backport photo picker via Google Play Services -->
|
||||
<service
|
||||
|
|
@ -168,7 +168,7 @@
|
|||
<activity
|
||||
android:name=".activities.DeepLinkActivity"
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.Revolt">
|
||||
android:theme="@style/Theme.Peptide">
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Android App Links Setup Instructions
|
||||
|
||||
This document provides instructions for setting up Android App Links for the Revolt app.
|
||||
This document provides instructions for setting up Android App Links for the Peptide app.
|
||||
|
||||
## What are Android App Links?
|
||||
|
||||
|
|
@ -45,8 +45,8 @@ Open the `assetlinks.json` file in this directory and replace the placeholder wi
|
|||
Upload the `assetlinks.json` file to the following location on your server:
|
||||
|
||||
```
|
||||
https://revolt.chat/.well-known/assetlinks.json
|
||||
https://app.revolt.chat/.well-known/assetlinks.json
|
||||
https://peptide.chat/.well-known/assetlinks.json
|
||||
https://app.peptide.chat/.well-known/assetlinks.json
|
||||
```
|
||||
|
||||
Make sure the file is accessible via HTTPS and returns with Content-Type: application/json.
|
||||
|
|
@ -56,7 +56,7 @@ Make sure the file is accessible via HTTPS and returns with Content-Type: applic
|
|||
Use the Android Debug Bridge (ADB) to test your App Links:
|
||||
|
||||
```bash
|
||||
adb shell am start -a android.intent.action.VIEW -d "https://revolt.chat/channels/CHANNEL_ID" chat.peptide
|
||||
adb shell am start -a android.intent.action.VIEW -d "https://peptide.chat/channels/CHANNEL_ID" chat.peptide
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ cmake_minimum_required(VERSION 3.22.1)
|
|||
# Since this is the top level CMakeLists.txt, the project name is also accessible
|
||||
# with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level
|
||||
# build script scope).
|
||||
project("revolt")
|
||||
project("peptide")
|
||||
|
||||
# Compile cmark in external/cmark
|
||||
add_subdirectory(external/cmark)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package chat.peptide
|
||||
|
||||
import android.app.Application
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.persistence.KVStorage
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
|
|
@ -9,15 +9,15 @@ import logcat.AndroidLogcatLogger
|
|||
import logcat.LogPriority
|
||||
|
||||
@HiltAndroidApp
|
||||
class RevoltApplication : Application() {
|
||||
class PeptideApplication : Application() {
|
||||
companion object {
|
||||
lateinit var instance: RevoltApplication
|
||||
lateinit var instance: PeptideApplication
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
AndroidLogcatLogger.installOnDebuggableApp(this, minPriority = LogPriority.VERBOSE)
|
||||
RevoltHttp // Trigger initialization
|
||||
PeptideHttp // Trigger initialization
|
||||
}
|
||||
|
||||
init {
|
||||
|
|
@ -30,6 +30,6 @@ class RevoltApplication : Application() {
|
|||
* Extension function to get KVStorage instance.
|
||||
* @return KVStorage instance
|
||||
*/
|
||||
fun RevoltApplication.getKVStorage(): KVStorage {
|
||||
fun PeptideApplication.getKVStorage(): KVStorage {
|
||||
return KVStorage(this)
|
||||
}
|
||||
|
|
@ -49,9 +49,9 @@ class DeepLinkActivity : AppCompatActivity() {
|
|||
if (Intent.ACTION_VIEW == appLinkAction && appLinkData != null) {
|
||||
Log.d(TAG, "Deep link received: $appLinkData")
|
||||
|
||||
// Check if this is a valid Revolt deep link
|
||||
if (!DeepLinkUtils.isRevoltDeepLink(appLinkData)) {
|
||||
Log.d(TAG, "Not a valid Revolt deep link: $appLinkData")
|
||||
// Check if this is a valid Peptide deep link
|
||||
if (!DeepLinkUtils.isPeptideDeepLink(appLinkData)) {
|
||||
Log.d(TAG, "Not a valid Peptide deep link: $appLinkData")
|
||||
startMainActivity()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ import androidx.lifecycle.ViewModel
|
|||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.routes.invites.fetchInviteByCode
|
||||
import chat.peptide.api.routes.invites.joinInviteByCode
|
||||
import chat.peptide.api.schemas.Invite
|
||||
|
|
@ -58,7 +58,7 @@ import chat.peptide.api.settings.LoadedSettings
|
|||
import chat.peptide.api.settings.SyncedSettings
|
||||
import chat.peptide.composables.generic.IconPlaceholder
|
||||
import chat.peptide.composables.generic.RemoteImage
|
||||
import chat.peptide.ui.theme.RevoltTheme
|
||||
import chat.peptide.ui.theme.PeptideTheme
|
||||
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
|
||||
import com.bumptech.glide.integration.compose.GlideImage
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
@ -90,19 +90,19 @@ class InviteViewModel : ViewModel() {
|
|||
_loadingFinished = loadingFinished
|
||||
}
|
||||
|
||||
private var _inviteResult by mutableStateOf<RsResult<Invite, RevoltError>?>(null)
|
||||
val inviteResult: RsResult<Invite, RevoltError>?
|
||||
private var _inviteResult by mutableStateOf<RsResult<Invite, PeptideError>?>(null)
|
||||
val inviteResult: RsResult<Invite, PeptideError>?
|
||||
get() = _inviteResult
|
||||
|
||||
fun setInviteResult(inviteResult: RsResult<Invite, RevoltError>?) {
|
||||
fun setInviteResult(inviteResult: RsResult<Invite, PeptideError>?) {
|
||||
_inviteResult = inviteResult
|
||||
}
|
||||
|
||||
private var _joinResult by mutableStateOf<RsResult<InviteJoined, RevoltError>?>(null)
|
||||
val joinResult: RsResult<InviteJoined, RevoltError>?
|
||||
private var _joinResult by mutableStateOf<RsResult<InviteJoined, PeptideError>?>(null)
|
||||
val joinResult: RsResult<InviteJoined, PeptideError>?
|
||||
get() = _joinResult
|
||||
|
||||
fun setJoinResult(joinResult: RsResult<InviteJoined, RevoltError>?) {
|
||||
fun setJoinResult(joinResult: RsResult<InviteJoined, PeptideError>?) {
|
||||
_joinResult = joinResult
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ fun InviteScreen(
|
|||
val inviteValid = if (viewModel.loadingFinished) (viewModel.inviteResult?.ok ?: false) else null
|
||||
val invite = viewModel.inviteResult?.value
|
||||
|
||||
RevoltTheme(
|
||||
PeptideTheme(
|
||||
requestedTheme = LoadedSettings.theme,
|
||||
colourOverrides = SyncedSettings.android.colourOverrides
|
||||
) {
|
||||
|
|
@ -180,7 +180,7 @@ fun InviteScreen(
|
|||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
GlideImage(
|
||||
model = "${RevoltAPI.getCurrentFilesUrl()}/banners/${invite?.serverBanner?.id}/${invite?.serverBanner?.filename}",
|
||||
model = "${PeptideAPI.getCurrentFilesUrl()}/banners/${invite?.serverBanner?.id}/${invite?.serverBanner?.filename}",
|
||||
contentScale = ContentScale.Crop,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
|
|
@ -205,7 +205,7 @@ fun InviteScreen(
|
|||
) {
|
||||
if (invite?.serverIcon != null) {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/icons/${invite.serverIcon.id}/${invite.serverIcon.filename}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/icons/${invite.serverIcon.id}/${invite.serverIcon.filename}",
|
||||
allowAnimation = false,
|
||||
description = viewModel.inviteResult?.value?.serverName
|
||||
?: stringResource(id = R.string.unknown),
|
||||
|
|
@ -274,7 +274,7 @@ fun InviteScreen(
|
|||
}
|
||||
|
||||
@Composable
|
||||
fun InvalidInviteError(error: RevoltError? = null, onDismissRequest: () -> Unit) {
|
||||
fun InvalidInviteError(error: PeptideError? = null, onDismissRequest: () -> Unit) {
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismissRequest,
|
||||
icon = {
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@ import androidx.navigation.compose.composable
|
|||
import androidx.navigation.compose.rememberNavController
|
||||
import chat.peptide.BuildConfig
|
||||
import chat.peptide.R
|
||||
import chat.peptide.RevoltApplication
|
||||
import chat.peptide.PeptideApplication
|
||||
import chat.peptide.api.ApplicationPlatform
|
||||
import chat.peptide.api.HitRateLimitException
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltAPI.setPlatform
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideAPI.setPlatform
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.UrlsStorageKeys
|
||||
import chat.peptide.api.api
|
||||
import chat.peptide.api.routes.microservices.geo.queryGeo
|
||||
|
|
@ -127,7 +127,7 @@ import chat.peptide.screens.settings.SettingsScreen
|
|||
import chat.peptide.screens.settings.channel.ChannelSettingsHome
|
||||
import chat.peptide.screens.settings.channel.ChannelSettingsOverview
|
||||
import chat.peptide.screens.settings.channel.ChannelSettingsPermissions
|
||||
import chat.peptide.ui.theme.RevoltTheme
|
||||
import chat.peptide.ui.theme.PeptideTheme
|
||||
import chat.peptide.utils.DeepLinkHandler
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
|
@ -167,9 +167,9 @@ class MainActivityViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun canReachRevolt(): Boolean {
|
||||
private suspend fun canReachPeptide(): Boolean {
|
||||
try {
|
||||
val res = RevoltHttp.get("/".api())
|
||||
val res = PeptideHttp.get("/".api())
|
||||
return res.status.value == 200
|
||||
} catch (_: Exception) {
|
||||
return false
|
||||
|
|
@ -199,7 +199,7 @@ class MainActivityViewModel @Inject constructor(
|
|||
|
||||
/**
|
||||
* Sets the default platform on application creation.
|
||||
* It retrieves the platform from key-value storage and sets it in the RevoltAPI.
|
||||
* It retrieves the platform from key-value storage and sets it in the PeptideAPI.
|
||||
* If the platform is not found or invalid, it logs the user out.
|
||||
*/
|
||||
fun setDefaultPlatformOnCreate() {
|
||||
|
|
@ -229,11 +229,11 @@ class MainActivityViewModel @Inject constructor(
|
|||
|
||||
isConnected.emit(hasInternetConnection())
|
||||
|
||||
Log.d("MainActivity", "Checking if we can reach Revolt")
|
||||
Log.d("MainActivity", "Checking if we can reach Peptide")
|
||||
|
||||
if (!isConnected.value) return@launch startWithoutDestination()
|
||||
|
||||
Log.d("MainActivity", "We can reach Revolt, checking if we're logged in")
|
||||
Log.d("MainActivity", "We can reach Peptide, checking if we're logged in")
|
||||
|
||||
val token = kvStorage.get("sessionToken")
|
||||
?: return@launch startWithDestination("choose-platform")
|
||||
|
|
@ -241,17 +241,17 @@ class MainActivityViewModel @Inject constructor(
|
|||
|
||||
Log.d(
|
||||
"MainActivity",
|
||||
"We have a session token, checking if it's valid and if we can still reach Revolt"
|
||||
"We have a session token, checking if it's valid and if we can still reach Peptide"
|
||||
)
|
||||
|
||||
val canReachRevolt = canReachRevolt()
|
||||
val canReachPeptide = canReachPeptide()
|
||||
val valid = try {
|
||||
RevoltAPI.checkSessionToken(token)
|
||||
PeptideAPI.checkSessionToken(token)
|
||||
} catch (_: Throwable) {
|
||||
false
|
||||
}
|
||||
|
||||
if (canReachRevolt && !valid) {
|
||||
if (canReachPeptide && !valid) {
|
||||
Log.d("MainActivity", "Session token is invalid, could not log in")
|
||||
couldNotLogIn.emit(true)
|
||||
} else {
|
||||
|
|
@ -278,8 +278,8 @@ class MainActivityViewModel @Inject constructor(
|
|||
|
||||
try {
|
||||
Log.d("MainActivity", "Onboarding state is complete, logging in")
|
||||
RevoltAPI.loginAs(token)
|
||||
RevoltAPI.setSessionId(id)
|
||||
PeptideAPI.loginAs(token)
|
||||
PeptideAPI.setSessionId(id)
|
||||
if (Experiments.usePolar.isEnabled) {
|
||||
startWithDestination("main")
|
||||
} else {
|
||||
|
|
@ -354,7 +354,7 @@ class MainActivity : AppCompatActivity() {
|
|||
override fun onResume() {
|
||||
super.onResume()
|
||||
DynamicColors.applyToActivityIfAvailable(this)
|
||||
DynamicColors.applyToActivitiesIfAvailable(RevoltApplication.instance)
|
||||
DynamicColors.applyToActivitiesIfAvailable(PeptideApplication.instance)
|
||||
@Suppress("DEPRECATION") // We are fixing a bug in the splash screen
|
||||
window.statusBarColor = Color.Transparent.toArgb()
|
||||
}
|
||||
|
|
@ -363,7 +363,7 @@ class MainActivity : AppCompatActivity() {
|
|||
override fun onConfigurationChanged(newConfig: android.content.res.Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
DynamicColors.applyToActivityIfAvailable(this)
|
||||
DynamicColors.applyToActivitiesIfAvailable(RevoltApplication.instance)
|
||||
DynamicColors.applyToActivitiesIfAvailable(PeptideApplication.instance)
|
||||
@Suppress("DEPRECATION") // We are fixing a bug in the splash screen
|
||||
window.statusBarColor = Color.Transparent.toArgb()
|
||||
}
|
||||
|
|
@ -384,7 +384,7 @@ class MainActivity : AppCompatActivity() {
|
|||
window.statusBarColor = Color.Transparent.toArgb()
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
|
||||
RevoltAPI.hydrateFromPersistentCache()
|
||||
PeptideAPI.hydrateFromPersistentCache()
|
||||
|
||||
// Handle deep link data if available
|
||||
handleDeepLinkData(intent)
|
||||
|
|
@ -520,9 +520,9 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
val RevoltTweenInt: FiniteAnimationSpec<IntOffset> = tween(400, easing = EaseInOutExpo)
|
||||
val RevoltTweenFloat: FiniteAnimationSpec<Float> = tween(400, easing = EaseInOutExpo)
|
||||
val RevoltTweenDp: FiniteAnimationSpec<Dp> = tween(400, easing = EaseInOutExpo)
|
||||
val PeptideTweenInt: FiniteAnimationSpec<IntOffset> = tween(400, easing = EaseInOutExpo)
|
||||
val PeptideTweenFloat: FiniteAnimationSpec<Float> = tween(400, easing = EaseInOutExpo)
|
||||
val PeptideTweenDp: FiniteAnimationSpec<Dp> = tween(400, easing = EaseInOutExpo)
|
||||
|
||||
val NavTweenInt: FiniteAnimationSpec<IntOffset> = tween(350, easing = EaseInOutExpo)
|
||||
val NavTweenFloat: FiniteAnimationSpec<Float> = tween(350, easing = EaseInOutExpo)
|
||||
|
|
@ -572,7 +572,7 @@ fun AppEntrypoint(
|
|||
|
||||
val navController = rememberNavController()
|
||||
|
||||
RevoltTheme(
|
||||
PeptideTheme(
|
||||
requestedTheme = LoadedSettings.theme,
|
||||
colourOverrides = SyncedSettings.android.colourOverrides,
|
||||
) {
|
||||
|
|
@ -715,7 +715,7 @@ fun AppEntrypoint(
|
|||
easing = EasingTokens.EmphasizedDecelerate
|
||||
),
|
||||
initialOffset = { it / 3 }
|
||||
) + fadeIn(animationSpec = RevoltTweenFloat)
|
||||
) + fadeIn(animationSpec = PeptideTweenFloat)
|
||||
}
|
||||
) {
|
||||
ChatRouterScreen(
|
||||
|
|
@ -748,7 +748,7 @@ fun AppEntrypoint(
|
|||
easing = EasingTokens.EmphasizedDecelerate
|
||||
),
|
||||
initialOffset = { it / 3 }
|
||||
) + fadeIn(animationSpec = RevoltTweenFloat) + scaleIn(
|
||||
) + fadeIn(animationSpec = PeptideTweenFloat) + scaleIn(
|
||||
animationSpec = tween(
|
||||
400,
|
||||
easing = EasingTokens.EmphasizedDecelerate
|
||||
|
|
@ -770,7 +770,7 @@ fun AppEntrypoint(
|
|||
easing = EasingTokens.EmphasizedDecelerate
|
||||
),
|
||||
initialOffset = { it }
|
||||
) + fadeIn(animationSpec = RevoltTweenFloat)
|
||||
) + fadeIn(animationSpec = PeptideTweenFloat)
|
||||
},
|
||||
exitTransition = {
|
||||
slideOutOfContainer(
|
||||
|
|
@ -780,7 +780,7 @@ fun AppEntrypoint(
|
|||
easing = EasingTokens.EmphasizedDecelerate
|
||||
),
|
||||
targetOffset = { it }
|
||||
) + fadeOut(animationSpec = RevoltTweenFloat)
|
||||
) + fadeOut(animationSpec = PeptideTweenFloat)
|
||||
}
|
||||
) { backStackEntry ->
|
||||
val channelId = backStackEntry.arguments?.getString("channelId") ?: ""
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
|
|||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.ChannelUtils
|
||||
import chat.peptide.api.routes.channel.sendMessage
|
||||
import chat.peptide.api.routes.microservices.autumn.FileArgs
|
||||
|
|
@ -68,7 +68,7 @@ import chat.peptide.composables.screens.chat.drawer.ChannelItemIconType
|
|||
import chat.peptide.composables.screens.chat.drawer.DMOrGroupItem
|
||||
import chat.peptide.persistence.KVStorage
|
||||
import chat.peptide.screens.chat.views.channel.ChannelScreenActivePane
|
||||
import chat.peptide.ui.theme.RevoltTheme
|
||||
import chat.peptide.ui.theme.PeptideTheme
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import io.ktor.http.ContentType
|
||||
|
|
@ -180,10 +180,10 @@ class ShareTargetScreenViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
suspend fun initialiseAPI() {
|
||||
if (!RevoltAPI.isLoggedIn()) {
|
||||
if (!PeptideAPI.isLoggedIn()) {
|
||||
val token = kvStorage.get("sessionToken") ?: return
|
||||
RevoltAPI.loginAs(token)
|
||||
RevoltAPI.initialize()
|
||||
PeptideAPI.loginAs(token)
|
||||
PeptideAPI.initialize()
|
||||
}
|
||||
apiIsReady = true
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ fun ShareTargetScreen(
|
|||
var channelSearchContent by remember { mutableStateOf("") }
|
||||
var selectedChannel by rememberSaveable { mutableStateOf<String?>(null) }
|
||||
|
||||
RevoltTheme(
|
||||
PeptideTheme(
|
||||
requestedTheme = LoadedSettings.theme,
|
||||
colourOverrides = SyncedSettings.android.colourOverrides
|
||||
) {
|
||||
|
|
@ -326,7 +326,7 @@ fun ShareTargetScreen(
|
|||
Box(
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
val filteredChannels = RevoltAPI.channelCache.values.asSequence().filter {
|
||||
val filteredChannels = PeptideAPI.channelCache.values.asSequence().filter {
|
||||
it.name?.contains(
|
||||
channelSearchContent,
|
||||
ignoreCase = true
|
||||
|
|
@ -346,7 +346,7 @@ fun ShareTargetScreen(
|
|||
ChannelType.Group, ChannelType.DirectMessage -> DMOrGroupItem(
|
||||
channel = channel,
|
||||
partner = ChannelUtils.resolveDMPartner(channel)?.let { u ->
|
||||
RevoltAPI.userCache[u]
|
||||
PeptideAPI.userCache[u]
|
||||
},
|
||||
isCurrent = selectedChannel == channel.id,
|
||||
hasUnread = false,
|
||||
|
|
@ -421,9 +421,9 @@ fun ShareTargetScreen(
|
|||
}
|
||||
}
|
||||
},
|
||||
channelType = RevoltAPI.channelCache[selectedChannel]?.channelType
|
||||
channelType = PeptideAPI.channelCache[selectedChannel]?.channelType
|
||||
?: ChannelType.TextChannel,
|
||||
channelName = RevoltAPI.channelCache[selectedChannel]?.name ?: "",
|
||||
channelName = PeptideAPI.channelCache[selectedChannel]?.name ?: "",
|
||||
)
|
||||
|
||||
AnimatedVisibility(viewModel.activeBottomPane is ChannelScreenActivePane.EmojiPicker) {
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.core.view.WindowCompat
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.schemas.AutumnResource
|
||||
import chat.peptide.api.settings.LoadedSettings
|
||||
import chat.peptide.api.settings.SyncedSettings
|
||||
import chat.peptide.providers.getAttachmentContentUri
|
||||
import chat.peptide.ui.theme.RevoltTheme
|
||||
import chat.peptide.ui.theme.PeptideTheme
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.statement.readBytes
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
@ -85,7 +85,7 @@ class ImageViewActivity : ComponentActivity() {
|
|||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ImageViewScreen(resource: AutumnResource, onClose: () -> Unit = {}) {
|
||||
val resourceUrl = "${RevoltAPI.getCurrentFilesUrl()}/attachments/${resource.id}/${resource.filename}"
|
||||
val resourceUrl = "${PeptideAPI.getCurrentFilesUrl()}/attachments/${resource.id}/${resource.filename}"
|
||||
|
||||
val context = LocalContext.current
|
||||
|
||||
|
|
@ -145,13 +145,13 @@ fun ImageViewScreen(resource: AutumnResource, onClose: () -> Unit = {}) {
|
|||
ContentValues().apply {
|
||||
put(MediaStore.Images.Media.DISPLAY_NAME, resource.filename)
|
||||
put(MediaStore.Images.Media.MIME_TYPE, resource.contentType)
|
||||
put(MediaStore.Images.Media.RELATIVE_PATH, "Pictures/Revolt")
|
||||
put(MediaStore.Images.Media.RELATIVE_PATH, "Pictures/Peptide")
|
||||
put(MediaStore.Images.Media.IS_PENDING, 1)
|
||||
}
|
||||
)
|
||||
}?.let { uri ->
|
||||
context.contentResolver.openOutputStream(uri).use { stream ->
|
||||
val image = RevoltHttp.get(resourceUrl).readBytes()
|
||||
val image = PeptideHttp.get(resourceUrl).readBytes()
|
||||
stream?.write(image)
|
||||
|
||||
context.applicationContext.let {
|
||||
|
|
@ -182,7 +182,7 @@ fun ImageViewScreen(resource: AutumnResource, onClose: () -> Unit = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
RevoltTheme(
|
||||
PeptideTheme(
|
||||
requestedTheme = LoadedSettings.theme,
|
||||
colourOverrides = SyncedSettings.android.colourOverrides
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ import androidx.lifecycle.lifecycleScope
|
|||
import androidx.media3.common.MediaItem
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.schemas.AutumnResource
|
||||
import chat.peptide.databinding.ActivityVideoplayerBinding
|
||||
import chat.peptide.providers.getAttachmentContentUri
|
||||
|
|
@ -54,7 +54,7 @@ class VideoViewActivity : FragmentActivity() {
|
|||
}
|
||||
|
||||
val resourceUrl =
|
||||
"${RevoltAPI.getCurrentFilesUrl()}/attachments/${autumnResource.id}/${autumnResource.filename}"
|
||||
"${PeptideAPI.getCurrentFilesUrl()}/attachments/${autumnResource.id}/${autumnResource.filename}"
|
||||
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
|
||||
|
|
@ -189,13 +189,13 @@ class VideoViewActivity : FragmentActivity() {
|
|||
ContentValues().apply {
|
||||
put(MediaStore.Video.Media.DISPLAY_NAME, resource.filename)
|
||||
put(MediaStore.Video.Media.MIME_TYPE, resource.contentType)
|
||||
put(MediaStore.Video.Media.RELATIVE_PATH, "Movies/Revolt")
|
||||
put(MediaStore.Video.Media.RELATIVE_PATH, "Movies/Peptide")
|
||||
put(MediaStore.Video.Media.IS_PENDING, 1)
|
||||
}
|
||||
)
|
||||
}?.let { uri ->
|
||||
this@VideoViewActivity.contentResolver.openOutputStream(uri).use { stream ->
|
||||
val video = RevoltHttp.get(resourceUrl).readBytes()
|
||||
val video = PeptideHttp.get(resourceUrl).readBytes()
|
||||
stream?.write(video)
|
||||
|
||||
this@VideoViewActivity.applicationContext.let {
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import android.os.Looper
|
|||
import android.util.Log
|
||||
import androidx.compose.runtime.mutableStateMapOf
|
||||
import chat.peptide.BuildConfig
|
||||
import chat.peptide.RevoltApplication
|
||||
import chat.peptide.api.RevoltAPI.initialize
|
||||
import chat.peptide.PeptideApplication
|
||||
import chat.peptide.api.PeptideAPI.initialize
|
||||
import chat.peptide.api.internals.Members
|
||||
import chat.peptide.api.realtime.DisconnectionState
|
||||
import chat.peptide.api.realtime.RealtimeSocket
|
||||
|
|
@ -58,7 +58,7 @@ import chat.peptide.api.schemas.Channel as ChannelSchema
|
|||
* Enum representing available platforms in the application.
|
||||
*/
|
||||
enum class ApplicationPlatform(val baseUrl: String) {
|
||||
REVOLT("https://api.revolt.chat"),
|
||||
REVOLT("https://api.peptide.chat"),
|
||||
PEP("https://peptide.chat/api");
|
||||
|
||||
companion object {
|
||||
|
|
@ -117,7 +117,7 @@ object UrlsStorageKeys {
|
|||
}
|
||||
|
||||
fun String.api(): String {
|
||||
return "${RevoltAPI.getCurrentBaseUrl()}$this"
|
||||
return "${PeptideAPI.getCurrentBaseUrl()}$this"
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -128,27 +128,27 @@ private fun getUrlForPlatform(platform: ApplicationPlatform, urlSelector: (Platf
|
|||
}
|
||||
|
||||
fun buildUserAgent(accessMethod: String = "Ktor"): String {
|
||||
return "$accessMethod RevoltAndroid/${BuildConfig.VERSION_NAME} " +
|
||||
return "$accessMethod PeptideAndroid/${BuildConfig.VERSION_NAME} " +
|
||||
"${BuildConfig.APPLICATION_ID} Android/${android.os.Build.VERSION.SDK_INT} " +
|
||||
"(${android.os.Build.MANUFACTURER} ${android.os.Build.DEVICE}) Kotlin/${KotlinVersion.CURRENT}"
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
val RevoltJson = Json {
|
||||
val PeptideJson = Json {
|
||||
ignoreUnknownKeys = true
|
||||
explicitNulls = false
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
val RevoltCbor = Cbor {
|
||||
val PeptideCbor = Cbor {
|
||||
ignoreUnknownKeys = true
|
||||
}
|
||||
|
||||
val RevoltHttp by lazy {
|
||||
val PeptideHttp by lazy {
|
||||
HttpClient(OkHttp) {
|
||||
install(DefaultRequest)
|
||||
install(ContentNegotiation) {
|
||||
json(RevoltJson)
|
||||
json(PeptideJson)
|
||||
}
|
||||
|
||||
install(WebSockets)
|
||||
|
|
@ -167,15 +167,15 @@ val RevoltHttp by lazy {
|
|||
install(Logging) { level = LogLevel.INFO }
|
||||
|
||||
val chuckerCollector = ChuckerCollector(
|
||||
context = RevoltApplication.instance,
|
||||
context = PeptideApplication.instance,
|
||||
showNotification = true,
|
||||
retentionPeriod = RetentionManager.Period.ONE_DAY
|
||||
)
|
||||
|
||||
val chuckerInterceptor = ChuckerInterceptor.Builder(RevoltApplication.instance)
|
||||
val chuckerInterceptor = ChuckerInterceptor.Builder(PeptideApplication.instance)
|
||||
.collector(chuckerCollector)
|
||||
.maxContentLength(250_000L)
|
||||
.redactHeaders(RevoltAPI.TOKEN_HEADER_NAME)
|
||||
.redactHeaders(PeptideAPI.TOKEN_HEADER_NAME)
|
||||
.alwaysReadResponseBody(true)
|
||||
.createShortcut(false)
|
||||
.build()
|
||||
|
|
@ -184,8 +184,8 @@ val RevoltHttp by lazy {
|
|||
addInterceptor { chain ->
|
||||
val request = chain.request().newBuilder()
|
||||
.apply {
|
||||
if (chain.request().headers[RevoltAPI.TOKEN_HEADER_NAME] == null) {
|
||||
header(RevoltAPI.TOKEN_HEADER_NAME, RevoltAPI.sessionToken)
|
||||
if (chain.request().headers[PeptideAPI.TOKEN_HEADER_NAME] == null) {
|
||||
header(PeptideAPI.TOKEN_HEADER_NAME, PeptideAPI.sessionToken)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
|
|
@ -195,7 +195,7 @@ val RevoltHttp by lazy {
|
|||
}
|
||||
|
||||
defaultRequest {
|
||||
url(RevoltAPI.getCurrentBaseUrl())
|
||||
url(PeptideAPI.getCurrentBaseUrl())
|
||||
header("User-Agent", buildUserAgent())
|
||||
}
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ val RevoltHttp by lazy {
|
|||
|
||||
val mainHandler = Handler(Looper.getMainLooper())
|
||||
|
||||
object RevoltAPI {
|
||||
object PeptideAPI {
|
||||
const val TOKEN_HEADER_NAME = "x-session-token"
|
||||
|
||||
val userCache = mutableStateMapOf<String, User>()
|
||||
|
|
@ -245,7 +245,7 @@ object RevoltAPI {
|
|||
* Saves the current platform selection to persistent storage.
|
||||
*/
|
||||
private suspend fun savePlatformSelection() {
|
||||
val kvStorage = RevoltApplication.instance.getKVStorage()
|
||||
val kvStorage = PeptideApplication.instance.getKVStorage()
|
||||
kvStorage.set(UrlsStorageKeys.PLATFORM, selectedApplicationPlatform.name)
|
||||
}
|
||||
|
||||
|
|
@ -253,7 +253,7 @@ object RevoltAPI {
|
|||
* Loads the platform selection from persistent storage.
|
||||
*/
|
||||
suspend fun loadPlatformSelection() {
|
||||
val kvStorage = RevoltApplication.instance.getKVStorage()
|
||||
val kvStorage = PeptideApplication.instance.getKVStorage()
|
||||
val applicationPlatformName = kvStorage.get(UrlsStorageKeys.PLATFORM) ?: ApplicationPlatform.REVOLT.name
|
||||
selectedApplicationPlatform = try {
|
||||
ApplicationPlatform.valueOf(applicationPlatformName)
|
||||
|
|
@ -304,19 +304,19 @@ object RevoltAPI {
|
|||
try {
|
||||
RealtimeSocket.connect(sessionToken)
|
||||
} catch (e: SocketException) {
|
||||
Log.d("RevoltAPI", "Socket closed, probably no big deal /// " + e.message)
|
||||
Log.d("PeptideAPI", "Socket closed, probably no big deal /// " + e.message)
|
||||
RealtimeSocket.updateDisconnectionState(DisconnectionState.Disconnected)
|
||||
} catch (e: Exception) {
|
||||
Log.e("RevoltAPI", "WebSocket error", e)
|
||||
Log.e("PeptideAPI", "WebSocket error", e)
|
||||
RealtimeSocket.updateDisconnectionState(DisconnectionState.Disconnected)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
if (e is InterruptedException) {
|
||||
Log.d("RevoltAPI", "Socket interrupted")
|
||||
Log.d("PeptideAPI", "Socket interrupted")
|
||||
} else {
|
||||
Log.e("RevoltAPI", "WebSocket error", e)
|
||||
Log.e("PeptideAPI", "WebSocket error", e)
|
||||
}
|
||||
RealtimeSocket.updateDisconnectionState(DisconnectionState.Disconnected)
|
||||
} catch (e: Exception) {
|
||||
|
|
@ -330,7 +330,7 @@ object RevoltAPI {
|
|||
connectWS()
|
||||
|
||||
// Send a ping every roughly 30 seconds else the socket dies
|
||||
// Same interval as the web clients (/revolt.js)
|
||||
// Same interval as the web clients (/peptide.js)
|
||||
// Note: This will run even if the socket is closed (sendPing will just exit early)
|
||||
mainHandler.post(object : Runnable {
|
||||
override fun run() {
|
||||
|
|
@ -398,7 +398,7 @@ object RevoltAPI {
|
|||
*/
|
||||
fun hydrateFromPersistentCache() {
|
||||
if (!openForLocalHydration) {
|
||||
Log.w("RevoltAPI", "Hydration is closed, but was called")
|
||||
Log.w("PeptideAPI", "Hydration is closed, but was called")
|
||||
// Stale data is worst case, let's track it even in prod
|
||||
Sentry.captureMessage("Local hydration called twice or after real data was fetched")
|
||||
return
|
||||
|
|
@ -476,7 +476,7 @@ object RevoltAPI {
|
|||
}
|
||||
|
||||
@Serializable
|
||||
data class RevoltError(val type: String)
|
||||
data class PeptideError(val type: String)
|
||||
|
||||
@Serializable
|
||||
data class RateLimitResponse(@SerialName("retry_after") val retryAfter: Int) {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package chat.peptide.api.internals
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.schemas.Channel
|
||||
import chat.peptide.api.schemas.Server
|
||||
import chat.peptide.api.schemas.User
|
||||
|
|
@ -19,7 +19,7 @@ object ChannelUtils {
|
|||
*/
|
||||
fun resolveName(channel: Channel): String? {
|
||||
return channel.name
|
||||
?: RevoltAPI.userCache[channel.recipients?.first { u -> u != RevoltAPI.selfId }]?.let {
|
||||
?: PeptideAPI.userCache[channel.recipients?.first { u -> u != PeptideAPI.selfId }]?.let {
|
||||
User.resolveDefaultName(
|
||||
it
|
||||
)
|
||||
|
|
@ -27,7 +27,7 @@ object ChannelUtils {
|
|||
}
|
||||
|
||||
fun resolveDMPartner(channel: Channel): String? {
|
||||
return channel.recipients?.firstOrNull { u -> u != RevoltAPI.selfId }
|
||||
return channel.recipients?.firstOrNull { u -> u != PeptideAPI.selfId }
|
||||
}
|
||||
|
||||
fun categoriseServerFlat(server: Server): List<CategorisedChannelList> {
|
||||
|
|
@ -42,7 +42,7 @@ object ChannelUtils {
|
|||
} ?: true
|
||||
}
|
||||
?.mapNotNull {
|
||||
RevoltAPI.channelCache[it]?.let { it1 ->
|
||||
PeptideAPI.channelCache[it]?.let { it1 ->
|
||||
CategorisedChannelList.Channel(it1)
|
||||
}
|
||||
} ?: emptyList()
|
||||
|
|
@ -53,7 +53,7 @@ object ChannelUtils {
|
|||
categories.forEach {
|
||||
output.add(it)
|
||||
val channels = it.category.channels?.mapNotNull { c ->
|
||||
RevoltAPI.channelCache[c]?.let { it1 ->
|
||||
PeptideAPI.channelCache[c]?.let { it1 ->
|
||||
CategorisedChannelList.Channel(it1)
|
||||
}
|
||||
} ?: emptyList()
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package chat.peptide.api.internals
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.SpecialUsers.PLATFORM_MODERATION_USER
|
||||
import chat.peptide.api.schemas.Channel
|
||||
import chat.peptide.api.schemas.ChannelType
|
||||
|
||||
object DirectMessages {
|
||||
fun unreadDMs(): List<Channel> {
|
||||
return RevoltAPI.channelCache.values
|
||||
return PeptideAPI.channelCache.values
|
||||
.filter {
|
||||
it.channelType in listOf(
|
||||
ChannelType.DirectMessage, ChannelType.Group
|
||||
|
|
@ -15,7 +15,7 @@ object DirectMessages {
|
|||
}
|
||||
.filter {
|
||||
it.id?.let { id ->
|
||||
RevoltAPI.unreads.hasUnread(
|
||||
PeptideAPI.unreads.hasUnread(
|
||||
id,
|
||||
it.lastMessageID!!,
|
||||
serverId = null
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
package chat.peptide.api.internals
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.schemas.User
|
||||
|
||||
object FriendRequests {
|
||||
fun getIncoming(): List<User> {
|
||||
return RevoltAPI.userCache.values.filter { user ->
|
||||
return PeptideAPI.userCache.values.filter { user ->
|
||||
user.relationship == "Incoming"
|
||||
}
|
||||
}
|
||||
|
||||
fun getOutgoing(): List<User> {
|
||||
return RevoltAPI.userCache.values.filter { user ->
|
||||
return PeptideAPI.userCache.values.filter { user ->
|
||||
user.relationship == "Outgoing"
|
||||
}
|
||||
}
|
||||
|
||||
fun getBlocked(): List<User> {
|
||||
return RevoltAPI.userCache.values.filter { user ->
|
||||
return PeptideAPI.userCache.values.filter { user ->
|
||||
user.relationship == "Blocked"
|
||||
}
|
||||
}
|
||||
|
||||
fun getOnlineFriends(): List<User> {
|
||||
return RevoltAPI.userCache.values.filter { user ->
|
||||
return PeptideAPI.userCache.values.filter { user ->
|
||||
user.relationship == "Friend" && user.online == true
|
||||
}
|
||||
}
|
||||
|
||||
fun getFriends(excludeOnline: Boolean = false): List<User> {
|
||||
return RevoltAPI.userCache.values.filter { user ->
|
||||
return PeptideAPI.userCache.values.filter { user ->
|
||||
user.relationship == "Friend" && if (excludeOnline) user.online == false else true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package chat.peptide.api.internals
|
|||
/**
|
||||
* Flags for messages that can be set to modify their behavior.
|
||||
*
|
||||
* See [Reference](https://docs.rs/revolt-models/latest/revolt_models/v0/enum.MessageFlags.html) for
|
||||
* See [Reference](https://docs.rs/peptide-models/latest/peptide_models/v0/enum.MessageFlags.html) for
|
||||
* values
|
||||
*
|
||||
* `shl 0` is not used.
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package chat.peptide.api.internals
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.api
|
||||
import chat.peptide.api.schemas.User
|
||||
|
||||
object ResourceLocations {
|
||||
fun userAvatarUrl(user: User?): String {
|
||||
if (user?.avatar != null) {
|
||||
return "${RevoltAPI.getCurrentFilesUrl()}/avatars/${user.avatar.id}"
|
||||
return "${PeptideAPI.getCurrentFilesUrl()}/avatars/${user.avatar.id}"
|
||||
}
|
||||
return "/users/${(user?.id ?: "").ifBlank { "0".repeat(26) }}/default_avatar".api()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package chat.peptide.api.internals
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.schemas.Channel
|
||||
import chat.peptide.api.schemas.ChannelType
|
||||
import chat.peptide.api.schemas.Member
|
||||
|
|
@ -27,8 +27,8 @@ object Roles {
|
|||
withColour: Boolean = false,
|
||||
hoisted: Boolean = false
|
||||
): Role? {
|
||||
val server = RevoltAPI.serverCache[serverId] ?: return null
|
||||
val member = RevoltAPI.members.getMember(serverId, userId) ?: return null
|
||||
val server = PeptideAPI.serverCache[serverId] ?: return null
|
||||
val member = PeptideAPI.members.getMember(serverId, userId) ?: return null
|
||||
|
||||
val roles = member.roles?.map { roleId ->
|
||||
server.roles?.get(roleId)
|
||||
|
|
@ -43,13 +43,13 @@ object Roles {
|
|||
}
|
||||
|
||||
fun inOrder(serverId: String, predicate: (Role) -> Boolean): List<Role> {
|
||||
val server = RevoltAPI.serverCache[serverId] ?: return emptyList()
|
||||
val server = PeptideAPI.serverCache[serverId] ?: return emptyList()
|
||||
|
||||
return server.roles?.values?.filter(predicate)?.sortedBy { it.rank } ?: emptyList()
|
||||
}
|
||||
|
||||
fun permissionFor(server: Server, member: Member): Long {
|
||||
val user = RevoltAPI.userCache[member.id?.user] ?: return 0L
|
||||
val user = PeptideAPI.userCache[member.id?.user] ?: return 0L
|
||||
|
||||
if (user.privileged == true) return PermissionBit.GrantAllSafe.value
|
||||
if (server.owner == member.id?.user) return PermissionBit.GrantAllSafe.value
|
||||
|
|
@ -71,7 +71,7 @@ object Roles {
|
|||
}
|
||||
|
||||
// TODO may not be exactly accurate
|
||||
// See https://github.com/revoltchat/revolt.js/blob/2ba023c879b2a53f9a3cc7042e6721c28dd970ba/src/permissions/calculator.ts#L80-L158
|
||||
// See https://github.com/peptidechat/peptide.js/blob/2ba023c879b2a53f9a3cc7042e6721c28dd970ba/src/permissions/calculator.ts#L80-L158
|
||||
fun permissionFor(channel: Channel, user: User? = null, member: Member? = null): Long {
|
||||
return when (channel.channelType) {
|
||||
ChannelType.SavedMessages -> BitDefaults.SavedMessages
|
||||
|
|
@ -80,13 +80,13 @@ object Roles {
|
|||
ChannelType.Group -> if (channel.owner == user?.id) PermissionBit.GrantAllSafe.value else BitDefaults.DirectMessages
|
||||
|
||||
ChannelType.TextChannel, ChannelType.VoiceChannel -> {
|
||||
val server = RevoltAPI.serverCache[channel.server]
|
||||
val server = PeptideAPI.serverCache[channel.server]
|
||||
// FIXME this is a stupid patch to prevent it from showing "no permission" on a channel on launch
|
||||
?: return PermissionBit.GrantAllSafe.value
|
||||
|
||||
if (server.owner == user?.id) return PermissionBit.GrantAllSafe.value
|
||||
|
||||
val chMember = member ?: RevoltAPI.members.getMember(
|
||||
val chMember = member ?: PeptideAPI.members.getMember(
|
||||
server.id ?: return 0L,
|
||||
user?.id ?: return 0L
|
||||
) ?: return 0L
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ fun Color.asHexJsonPrimitiveString(): JsonPrimitive {
|
|||
object ThemeCompat {
|
||||
@Composable
|
||||
fun materialThemeAsDiscoverTheme(materialTheme: MaterialTheme): JsonObject {
|
||||
// https://github.com/revoltchat/discover/blob/6effdf4a611e89b38b5e6bccefa1cd999e4b545f/styles/variables.scss
|
||||
// https://github.com/peptidechat/discover/blob/6effdf4a611e89b38b5e6bccefa1cd999e4b545f/styles/variables.scss
|
||||
return JsonObject(
|
||||
mapOf(
|
||||
"accent" to materialTheme.colorScheme.primary.asHexJsonPrimitiveString(),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package chat.peptide.api.internals
|
||||
|
||||
import androidx.core.net.toUri
|
||||
import chat.peptide.api.RevoltCbor
|
||||
import chat.peptide.api.PeptideCbor
|
||||
import chat.peptide.api.schemas.User
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.Serializable
|
||||
|
|
@ -21,8 +21,8 @@ data class UserQRContents(
|
|||
object UserQR {
|
||||
@OptIn(ExperimentalSerializationApi::class, ExperimentalEncodingApi::class)
|
||||
fun contents(user: User): String {
|
||||
return "https://revolt.chat/qr?" + Base64.encode(
|
||||
RevoltCbor.encodeToByteArray(
|
||||
return "https://peptide.chat/qr?" + Base64.encode(
|
||||
PeptideCbor.encodeToByteArray(
|
||||
UserQRContents.serializer(),
|
||||
UserQRContents(
|
||||
format = "rqr\$user\$0",
|
||||
|
|
@ -45,7 +45,7 @@ object UserQR {
|
|||
val uri = uriString.toUri()
|
||||
val base64 = uri.query ?: return null
|
||||
val decodedBytes = Base64.decode(base64)
|
||||
RevoltCbor.decodeFromByteArray(UserQRContents.serializer(), decodedBytes)
|
||||
PeptideCbor.decodeFromByteArray(UserQRContents.serializer(), decodedBytes)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ package chat.peptide.api.realtime
|
|||
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import chat.peptide.RevoltApplication
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.PeptideApplication
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.realtime.frames.receivable.AnyFrame
|
||||
import chat.peptide.api.realtime.frames.receivable.BulkFrame
|
||||
import chat.peptide.api.realtime.frames.receivable.ChannelAckFrame
|
||||
|
|
@ -69,7 +69,7 @@ object RealtimeSocket {
|
|||
var socket: WebSocketSession? = null
|
||||
|
||||
private val channelRegistrator: ChannelRegistrator
|
||||
get() = ChannelRegistrator(RevoltApplication.instance)
|
||||
get() = ChannelRegistrator(PeptideApplication.instance)
|
||||
|
||||
private var _disconnectionState = mutableStateOf(DisconnectionState.Reconnecting)
|
||||
val disconnectionState: DisconnectionState
|
||||
|
|
@ -87,7 +87,7 @@ object RealtimeSocket {
|
|||
|
||||
socket?.close(CloseReason(CloseReason.Codes.NORMAL, "Reconnecting to websocket."))
|
||||
|
||||
RevoltHttp.ws(RevoltAPI.getCurrentWebSocketUrl()) {
|
||||
PeptideHttp.ws(PeptideAPI.getCurrentWebSocketUrl()) {
|
||||
socket = this
|
||||
|
||||
Log.d("RealtimeSocket", "Connected to websocket.")
|
||||
|
|
@ -97,7 +97,7 @@ object RealtimeSocket {
|
|||
// Send authorization frame
|
||||
val authFrame = AuthorizationFrame("Authenticate", token)
|
||||
val authFrameString =
|
||||
RevoltJson.encodeToString(AuthorizationFrame.serializer(), authFrame)
|
||||
PeptideJson.encodeToString(AuthorizationFrame.serializer(), authFrame)
|
||||
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
|
|
@ -108,13 +108,13 @@ object RealtimeSocket {
|
|||
)
|
||||
}"
|
||||
)
|
||||
send(RevoltJson.encodeToString(AuthorizationFrame.serializer(), authFrame))
|
||||
send(PeptideJson.encodeToString(AuthorizationFrame.serializer(), authFrame))
|
||||
|
||||
incoming.consumeEach { frame ->
|
||||
if (frame is Frame.Text) {
|
||||
val frameString = frame.readText()
|
||||
val frameType =
|
||||
RevoltJson.decodeFromString(AnyFrame.serializer(), frameString).type
|
||||
PeptideJson.decodeFromString(AnyFrame.serializer(), frameString).type
|
||||
|
||||
handleFrame(frameType, frameString)
|
||||
}
|
||||
|
|
@ -126,29 +126,29 @@ object RealtimeSocket {
|
|||
if (disconnectionState != DisconnectionState.Connected) return
|
||||
|
||||
val pingPacket = PingFrame("Ping", System.currentTimeMillis())
|
||||
socket?.send(RevoltJson.encodeToString(PingFrame.serializer(), pingPacket))
|
||||
socket?.send(PeptideJson.encodeToString(PingFrame.serializer(), pingPacket))
|
||||
Log.d("RealtimeSocket", "Sent ping frame with ${pingPacket.data}")
|
||||
}
|
||||
|
||||
private suspend fun handleFrame(type: String, rawFrame: String) {
|
||||
when (type) {
|
||||
"Pong" -> {
|
||||
val pongFrame = RevoltJson.decodeFromString(PongFrame.serializer(), rawFrame)
|
||||
val pongFrame = PeptideJson.decodeFromString(PongFrame.serializer(), rawFrame)
|
||||
Log.d("RealtimeSocket", "Received pong frame for ${pongFrame.data}")
|
||||
}
|
||||
|
||||
"Bulk" -> {
|
||||
val bulkFrame = RevoltJson.decodeFromString(BulkFrame.serializer(), rawFrame)
|
||||
val bulkFrame = PeptideJson.decodeFromString(BulkFrame.serializer(), rawFrame)
|
||||
Log.d("RealtimeSocket", "Received bulk frame with ${bulkFrame.v.size} sub-frames.")
|
||||
bulkFrame.v.forEach { subFrame ->
|
||||
val subFrameType =
|
||||
RevoltJson.decodeFromString(AnyFrame.serializer(), subFrame.toString()).type
|
||||
PeptideJson.decodeFromString(AnyFrame.serializer(), subFrame.toString()).type
|
||||
handleFrame(subFrameType, subFrame.toString())
|
||||
}
|
||||
}
|
||||
|
||||
"Ready" -> {
|
||||
val readyFrame = RevoltJson.decodeFromString(ReadyFrame.serializer(), rawFrame)
|
||||
val readyFrame = PeptideJson.decodeFromString(ReadyFrame.serializer(), rawFrame)
|
||||
|
||||
logcat {
|
||||
"Received ready frame with ${readyFrame.users.size} users, " +
|
||||
|
|
@ -160,11 +160,11 @@ object RealtimeSocket {
|
|||
|
||||
Log.d("RealtimeSocket", "Adding users to cache.")
|
||||
val userMap = readyFrame.users.associateBy { it.id!! }
|
||||
RevoltAPI.userCache.putAll(userMap)
|
||||
PeptideAPI.userCache.putAll(userMap)
|
||||
|
||||
Log.d("RealtimeSocket", "Adding servers to cache.")
|
||||
val serverMap = readyFrame.servers.associateBy { it.id!! }
|
||||
RevoltAPI.serverCache.putAll(serverMap)
|
||||
PeptideAPI.serverCache.putAll(serverMap)
|
||||
|
||||
// Cache servers in persistent local database
|
||||
readyFrame.servers.map {
|
||||
|
|
@ -195,12 +195,12 @@ object RealtimeSocket {
|
|||
"Deleted server $it from local database due to not being in ready frame."
|
||||
)
|
||||
// Conversely, remove the server from the API state
|
||||
RevoltAPI.serverCache.remove(it)
|
||||
PeptideAPI.serverCache.remove(it)
|
||||
}
|
||||
|
||||
Log.d("RealtimeSocket", "Adding channels to cache.")
|
||||
val channelMap = readyFrame.channels.associateBy { it.id!! }
|
||||
RevoltAPI.channelCache.putAll(channelMap)
|
||||
PeptideAPI.channelCache.putAll(channelMap)
|
||||
|
||||
// Cache channels in persistent local database
|
||||
readyFrame.channels.map {
|
||||
|
|
@ -215,7 +215,7 @@ object RealtimeSocket {
|
|||
it.name,
|
||||
it.owner,
|
||||
it.description,
|
||||
if (it.channelType == ChannelType.DirectMessage) it.recipients?.firstOrNull { u -> u != RevoltAPI.selfId } else null,
|
||||
if (it.channelType == ChannelType.DirectMessage) it.recipients?.firstOrNull { u -> u != PeptideAPI.selfId } else null,
|
||||
it.icon?.id,
|
||||
it.lastMessageID,
|
||||
if (it.active == true) 1L else 0L,
|
||||
|
|
@ -236,21 +236,21 @@ object RealtimeSocket {
|
|||
"Deleted channel $it from local database due to not being in ready frame."
|
||||
)
|
||||
// Conversely, remove the channel from the API state
|
||||
RevoltAPI.channelCache.remove(it)
|
||||
PeptideAPI.channelCache.remove(it)
|
||||
}
|
||||
|
||||
Log.d("RealtimeSocket", "Adding emojis to cache.")
|
||||
val emojiMap = readyFrame.emojis.associateBy { it.id!! }
|
||||
RevoltAPI.emojiCache.putAll(emojiMap)
|
||||
PeptideAPI.emojiCache.putAll(emojiMap)
|
||||
|
||||
Log.d("RealtimeSocket", "Registering push notification channels.")
|
||||
channelRegistrator.register()
|
||||
|
||||
RevoltAPI.closeHydration()
|
||||
PeptideAPI.closeHydration()
|
||||
}
|
||||
|
||||
"Message" -> {
|
||||
val messageFrame = RevoltJson.decodeFromString(MessageFrame.serializer(), rawFrame)
|
||||
val messageFrame = PeptideJson.decodeFromString(MessageFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received message frame for ${messageFrame.id} in channel ${messageFrame.channel}."
|
||||
|
|
@ -261,30 +261,30 @@ object RealtimeSocket {
|
|||
return
|
||||
}
|
||||
|
||||
RevoltAPI.messageCache[messageFrame.id] = messageFrame
|
||||
PeptideAPI.messageCache[messageFrame.id] = messageFrame
|
||||
|
||||
messageFrame.channel?.let {
|
||||
if (RevoltAPI.channelCache[it] == null) {
|
||||
if (PeptideAPI.channelCache[it] == null) {
|
||||
Log.d("RealtimeSocket", "Channel $it not found in cache. Ignoring.")
|
||||
return
|
||||
}
|
||||
|
||||
RevoltAPI.channelCache[it] =
|
||||
RevoltAPI.channelCache[it]!!.copy(lastMessageID = messageFrame.id)
|
||||
PeptideAPI.channelCache[it] =
|
||||
PeptideAPI.channelCache[it]!!.copy(lastMessageID = messageFrame.id)
|
||||
|
||||
RevoltAPI.wsFrameChannel.send(messageFrame)
|
||||
PeptideAPI.wsFrameChannel.send(messageFrame)
|
||||
}
|
||||
}
|
||||
|
||||
"MessageAppend" -> {
|
||||
val messageAppendFrame =
|
||||
RevoltJson.decodeFromString(MessageAppendFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(MessageAppendFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received message append frame for ${messageAppendFrame.id} in channel ${messageAppendFrame.channel}."
|
||||
)
|
||||
|
||||
var message = RevoltAPI.messageCache[messageAppendFrame.id]
|
||||
var message = PeptideAPI.messageCache[messageAppendFrame.id]
|
||||
|
||||
if (message == null) {
|
||||
Log.d(
|
||||
|
|
@ -298,20 +298,20 @@ object RealtimeSocket {
|
|||
message = message!!.copy(embeds = message!!.embeds?.plus(it) ?: it)
|
||||
}
|
||||
|
||||
RevoltAPI.messageCache[messageAppendFrame.id] = message!!
|
||||
PeptideAPI.messageCache[messageAppendFrame.id] = message!!
|
||||
|
||||
RevoltAPI.wsFrameChannel.send(messageAppendFrame)
|
||||
PeptideAPI.wsFrameChannel.send(messageAppendFrame)
|
||||
}
|
||||
|
||||
"MessageUpdate" -> {
|
||||
val messageUpdateFrame =
|
||||
RevoltJson.decodeFromString(MessageUpdateFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(MessageUpdateFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received message update frame for ${messageUpdateFrame.id} in channel ${messageUpdateFrame.channel}."
|
||||
)
|
||||
|
||||
val oldMessage = RevoltAPI.messageCache[messageUpdateFrame.id]
|
||||
val oldMessage = PeptideAPI.messageCache[messageUpdateFrame.id]
|
||||
if (oldMessage == null) {
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
|
|
@ -323,7 +323,7 @@ object RealtimeSocket {
|
|||
val rawMessage: MessageFrame
|
||||
try {
|
||||
rawMessage =
|
||||
RevoltJson.decodeFromJsonElement(
|
||||
PeptideJson.decodeFromJsonElement(
|
||||
MessageFrame.serializer(),
|
||||
messageUpdateFrame.data
|
||||
)
|
||||
|
|
@ -337,28 +337,28 @@ object RealtimeSocket {
|
|||
"Merging message ${messageUpdateFrame.id} with updated partial."
|
||||
)
|
||||
|
||||
RevoltAPI.messageCache[messageUpdateFrame.id] =
|
||||
PeptideAPI.messageCache[messageUpdateFrame.id] =
|
||||
oldMessage.mergeWithPartial(rawMessage)
|
||||
|
||||
messageUpdateFrame.channel.let {
|
||||
if (RevoltAPI.channelCache[it] == null) {
|
||||
if (PeptideAPI.channelCache[it] == null) {
|
||||
Log.d("RealtimeSocket", "Channel $it not found in cache. Ignoring.")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
RevoltAPI.wsFrameChannel.send(messageUpdateFrame)
|
||||
PeptideAPI.wsFrameChannel.send(messageUpdateFrame)
|
||||
}
|
||||
|
||||
"MessageDelete" -> {
|
||||
val messageDeleteFrame =
|
||||
RevoltJson.decodeFromString(MessageDeleteFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(MessageDeleteFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received message react frame for ${messageDeleteFrame.id}."
|
||||
)
|
||||
|
||||
val message = RevoltAPI.messageCache[messageDeleteFrame.id]
|
||||
val message = PeptideAPI.messageCache[messageDeleteFrame.id]
|
||||
if (message == null) {
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
|
|
@ -367,19 +367,19 @@ object RealtimeSocket {
|
|||
return
|
||||
}
|
||||
|
||||
RevoltAPI.messageCache.remove(messageDeleteFrame.id)
|
||||
RevoltAPI.wsFrameChannel.send(messageDeleteFrame)
|
||||
PeptideAPI.messageCache.remove(messageDeleteFrame.id)
|
||||
PeptideAPI.wsFrameChannel.send(messageDeleteFrame)
|
||||
}
|
||||
|
||||
"MessageReact" -> {
|
||||
val messageReactFrame =
|
||||
RevoltJson.decodeFromString(MessageReactFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(MessageReactFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received message react frame for ${messageReactFrame.id}."
|
||||
)
|
||||
|
||||
val oldMessage = RevoltAPI.messageCache[messageReactFrame.id]
|
||||
val oldMessage = PeptideAPI.messageCache[messageReactFrame.id]
|
||||
if (oldMessage == null) {
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
|
|
@ -394,21 +394,21 @@ object RealtimeSocket {
|
|||
forEmoji.add(messageReactFrame.user_id)
|
||||
reactions[messageReactFrame.emoji_id] = forEmoji
|
||||
|
||||
RevoltAPI.messageCache[messageReactFrame.id] =
|
||||
PeptideAPI.messageCache[messageReactFrame.id] =
|
||||
oldMessage.copy(reactions = reactions)
|
||||
|
||||
RevoltAPI.wsFrameChannel.send(messageReactFrame)
|
||||
PeptideAPI.wsFrameChannel.send(messageReactFrame)
|
||||
}
|
||||
|
||||
"MessageUnreact" -> {
|
||||
val messageUnreactFrame =
|
||||
RevoltJson.decodeFromString(MessageReactFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(MessageReactFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received message unreact frame for ${messageUnreactFrame.id}."
|
||||
)
|
||||
|
||||
val oldMessage = RevoltAPI.messageCache[messageUnreactFrame.id]
|
||||
val oldMessage = PeptideAPI.messageCache[messageUnreactFrame.id]
|
||||
if (oldMessage == null) {
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
|
|
@ -428,38 +428,38 @@ object RealtimeSocket {
|
|||
reactions[messageUnreactFrame.emoji_id] = forEmoji
|
||||
}
|
||||
|
||||
RevoltAPI.messageCache[messageUnreactFrame.id] =
|
||||
PeptideAPI.messageCache[messageUnreactFrame.id] =
|
||||
oldMessage.copy(reactions = reactions)
|
||||
|
||||
RevoltAPI.wsFrameChannel.send(messageUnreactFrame)
|
||||
PeptideAPI.wsFrameChannel.send(messageUnreactFrame)
|
||||
}
|
||||
|
||||
"UserUpdate" -> {
|
||||
val userUpdateFrame =
|
||||
RevoltJson.decodeFromString(UserUpdateFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(UserUpdateFrame.serializer(), rawFrame)
|
||||
|
||||
val existing = RevoltAPI.userCache[userUpdateFrame.id]
|
||||
val existing = PeptideAPI.userCache[userUpdateFrame.id]
|
||||
?: return // if we don't have the user no point in updating it
|
||||
|
||||
if (userUpdateFrame.clear != null) {
|
||||
if (userUpdateFrame.clear.contains("Avatar")) {
|
||||
RevoltAPI.userCache[userUpdateFrame.id] =
|
||||
PeptideAPI.userCache[userUpdateFrame.id] =
|
||||
existing.copy(avatar = null)
|
||||
}
|
||||
}
|
||||
|
||||
RevoltAPI.userCache[userUpdateFrame.id] =
|
||||
PeptideAPI.userCache[userUpdateFrame.id] =
|
||||
existing.mergeWithPartial(userUpdateFrame.data)
|
||||
}
|
||||
|
||||
"UserRelationship" -> {
|
||||
val userRelationshipFrame =
|
||||
RevoltJson.decodeFromString(UserRelationshipFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(UserRelationshipFrame.serializer(), rawFrame)
|
||||
|
||||
val existing = RevoltAPI.userCache[userRelationshipFrame.user.id]
|
||||
val existing = PeptideAPI.userCache[userRelationshipFrame.user.id]
|
||||
|
||||
if (existing == null && userRelationshipFrame.user.id != null) {
|
||||
RevoltAPI.userCache[userRelationshipFrame.user.id] =
|
||||
PeptideAPI.userCache[userRelationshipFrame.user.id] =
|
||||
userRelationshipFrame.user.copy(
|
||||
relationship = userRelationshipFrame.status ?: "None"
|
||||
)
|
||||
|
|
@ -467,7 +467,7 @@ object RealtimeSocket {
|
|||
val merged = existing.mergeWithPartial(userRelationshipFrame.user).copy(
|
||||
relationship = userRelationshipFrame.status ?: "None"
|
||||
)
|
||||
RevoltAPI.userCache[userRelationshipFrame.user.id] = merged
|
||||
PeptideAPI.userCache[userRelationshipFrame.user.id] = merged
|
||||
} else {
|
||||
Log.w("RealtimeSocket", "Invalid UserRelationship frame: $rawFrame")
|
||||
}
|
||||
|
|
@ -475,13 +475,13 @@ object RealtimeSocket {
|
|||
|
||||
"ChannelUpdate" -> {
|
||||
val channelUpdateFrame =
|
||||
RevoltJson.decodeFromString(ChannelUpdateFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ChannelUpdateFrame.serializer(), rawFrame)
|
||||
|
||||
val existing = RevoltAPI.channelCache[channelUpdateFrame.id]
|
||||
val existing = PeptideAPI.channelCache[channelUpdateFrame.id]
|
||||
?: return // if we don't have the channel no point in updating it
|
||||
|
||||
val combined = existing.mergeWithPartial(channelUpdateFrame.data)
|
||||
RevoltAPI.channelCache[channelUpdateFrame.id] = combined
|
||||
PeptideAPI.channelCache[channelUpdateFrame.id] = combined
|
||||
|
||||
database.channelQueries.upsert(
|
||||
channelUpdateFrame.id,
|
||||
|
|
@ -490,7 +490,7 @@ object RealtimeSocket {
|
|||
combined.name,
|
||||
combined.owner,
|
||||
combined.description,
|
||||
if (combined.channelType == ChannelType.DirectMessage) combined.recipients?.firstOrNull { u -> u != RevoltAPI.selfId } else null,
|
||||
if (combined.channelType == ChannelType.DirectMessage) combined.recipients?.firstOrNull { u -> u != PeptideAPI.selfId } else null,
|
||||
combined.icon?.id,
|
||||
combined.lastMessageID,
|
||||
if (combined.active == true) 1L else 0L,
|
||||
|
|
@ -501,14 +501,14 @@ object RealtimeSocket {
|
|||
|
||||
"ChannelCreate" -> {
|
||||
val channelCreateFrame =
|
||||
RevoltJson.decodeFromString(Channel.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(Channel.serializer(), rawFrame)
|
||||
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received channel create frame for ${channelCreateFrame.id}, with name ${channelCreateFrame.name}. Adding to cache."
|
||||
)
|
||||
|
||||
RevoltAPI.channelCache[channelCreateFrame.id!!] = channelCreateFrame
|
||||
PeptideAPI.channelCache[channelCreateFrame.id!!] = channelCreateFrame
|
||||
database.channelQueries.upsert(
|
||||
channelCreateFrame.id,
|
||||
channelCreateFrame.channelType?.value ?: ChannelType.TextChannel.value,
|
||||
|
|
@ -516,7 +516,7 @@ object RealtimeSocket {
|
|||
channelCreateFrame.name,
|
||||
channelCreateFrame.owner,
|
||||
channelCreateFrame.description,
|
||||
if (channelCreateFrame.channelType == ChannelType.DirectMessage) channelCreateFrame.recipients?.firstOrNull { u -> u != RevoltAPI.selfId } else null,
|
||||
if (channelCreateFrame.channelType == ChannelType.DirectMessage) channelCreateFrame.recipients?.firstOrNull { u -> u != PeptideAPI.selfId } else null,
|
||||
channelCreateFrame.icon?.id,
|
||||
channelCreateFrame.lastMessageID,
|
||||
if (channelCreateFrame.active == true) 1L else 0L,
|
||||
|
|
@ -527,13 +527,13 @@ object RealtimeSocket {
|
|||
|
||||
"ChannelDelete" -> {
|
||||
val channelDeleteFrame =
|
||||
RevoltJson.decodeFromString(ChannelDeleteFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ChannelDeleteFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received channel delete frame for ${channelDeleteFrame.id}. Removing from cache."
|
||||
)
|
||||
|
||||
val currentChannel = RevoltAPI.channelCache[channelDeleteFrame.id]
|
||||
val currentChannel = PeptideAPI.channelCache[channelDeleteFrame.id]
|
||||
if (currentChannel == null) {
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
|
|
@ -542,11 +542,11 @@ object RealtimeSocket {
|
|||
return
|
||||
}
|
||||
|
||||
RevoltAPI.channelCache.remove(channelDeleteFrame.id)
|
||||
PeptideAPI.channelCache.remove(channelDeleteFrame.id)
|
||||
database.channelQueries.delete(channelDeleteFrame.id)
|
||||
|
||||
if (currentChannel.server != null) {
|
||||
val existingServer = RevoltAPI.serverCache[currentChannel.server]
|
||||
val existingServer = PeptideAPI.serverCache[currentChannel.server]
|
||||
|
||||
if (existingServer == null) {
|
||||
Log.d(
|
||||
|
|
@ -556,39 +556,39 @@ object RealtimeSocket {
|
|||
return
|
||||
}
|
||||
|
||||
RevoltAPI.serverCache[currentChannel.server] = existingServer.copy(
|
||||
PeptideAPI.serverCache[currentChannel.server] = existingServer.copy(
|
||||
channels = existingServer.channels?.filter { it != channelDeleteFrame.id }
|
||||
?: emptyList()
|
||||
)
|
||||
}
|
||||
|
||||
RevoltAPI.wsFrameChannel.send(channelDeleteFrame)
|
||||
PeptideAPI.wsFrameChannel.send(channelDeleteFrame)
|
||||
}
|
||||
|
||||
"ChannelAck" -> {
|
||||
val channelAckFrame =
|
||||
RevoltJson.decodeFromString(ChannelAckFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ChannelAckFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received channel ack frame for ${channelAckFrame.id} with new newest ${channelAckFrame.messageId}."
|
||||
)
|
||||
|
||||
RevoltAPI.unreads.processExternalAck(channelAckFrame.id, channelAckFrame.messageId)
|
||||
PeptideAPI.unreads.processExternalAck(channelAckFrame.id, channelAckFrame.messageId)
|
||||
}
|
||||
|
||||
"ServerCreate" -> {
|
||||
val serverCreateFrame =
|
||||
RevoltJson.decodeFromString(ServerCreateFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ServerCreateFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received server create frame for ${serverCreateFrame.id}, with name ${serverCreateFrame.server.name}. Adding to cache."
|
||||
)
|
||||
|
||||
RevoltAPI.serverCache[serverCreateFrame.id] = serverCreateFrame.server
|
||||
PeptideAPI.serverCache[serverCreateFrame.id] = serverCreateFrame.server
|
||||
|
||||
serverCreateFrame.channels.forEach { channel ->
|
||||
if (channel.id == null) return@forEach
|
||||
RevoltAPI.channelCache[channel.id] = channel
|
||||
PeptideAPI.channelCache[channel.id] = channel
|
||||
}
|
||||
|
||||
if (serverCreateFrame.server.owner != null && serverCreateFrame.server.name != null) {
|
||||
|
|
@ -606,35 +606,35 @@ object RealtimeSocket {
|
|||
|
||||
"ChannelStartTyping" -> {
|
||||
val channelStartTypingFrame =
|
||||
RevoltJson.decodeFromString(ChannelStartTypingFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ChannelStartTypingFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received channel start typing frame for ${channelStartTypingFrame.id}."
|
||||
)
|
||||
|
||||
RevoltAPI.wsFrameChannel.send(channelStartTypingFrame)
|
||||
PeptideAPI.wsFrameChannel.send(channelStartTypingFrame)
|
||||
}
|
||||
|
||||
"ChannelStopTyping" -> {
|
||||
val channelStopTypingFrame =
|
||||
RevoltJson.decodeFromString(ChannelStopTypingFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ChannelStopTypingFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received channel stop typing frame for ${channelStopTypingFrame.id}."
|
||||
)
|
||||
|
||||
RevoltAPI.wsFrameChannel.send(channelStopTypingFrame)
|
||||
PeptideAPI.wsFrameChannel.send(channelStopTypingFrame)
|
||||
}
|
||||
|
||||
"ServerUpdate" -> {
|
||||
val serverUpdateFrame =
|
||||
RevoltJson.decodeFromString(ServerUpdateFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ServerUpdateFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received server update frame for ${serverUpdateFrame.id}."
|
||||
)
|
||||
|
||||
val existing = RevoltAPI.serverCache[serverUpdateFrame.id]
|
||||
val existing = PeptideAPI.serverCache[serverUpdateFrame.id]
|
||||
?: return // if we don't have the server no point in updating it
|
||||
|
||||
var updated =
|
||||
|
|
@ -649,7 +649,7 @@ object RealtimeSocket {
|
|||
}
|
||||
}
|
||||
|
||||
RevoltAPI.serverCache[serverUpdateFrame.id] = updated
|
||||
PeptideAPI.serverCache[serverUpdateFrame.id] = updated
|
||||
|
||||
if (updated.id != null && updated.owner != null && updated.name != null) {
|
||||
try {
|
||||
|
|
@ -670,25 +670,25 @@ object RealtimeSocket {
|
|||
|
||||
"ServerDelete" -> {
|
||||
val serverDeleteFrame =
|
||||
RevoltJson.decodeFromString(ServerDeleteFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ServerDeleteFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received server delete frame for ${serverDeleteFrame.id}."
|
||||
)
|
||||
|
||||
RevoltAPI.serverCache.remove(serverDeleteFrame.id)
|
||||
PeptideAPI.serverCache.remove(serverDeleteFrame.id)
|
||||
database.serverQueries.delete(serverDeleteFrame.id)
|
||||
}
|
||||
|
||||
"ServerMemberUpdate" -> {
|
||||
val serverMemberUpdateFrame =
|
||||
RevoltJson.decodeFromString(ServerMemberUpdateFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ServerMemberUpdateFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received server member update frame for ${serverMemberUpdateFrame.id.user} in ${serverMemberUpdateFrame.id.server}."
|
||||
)
|
||||
|
||||
val existing = RevoltAPI.members.getMember(
|
||||
val existing = PeptideAPI.members.getMember(
|
||||
serverMemberUpdateFrame.id.server,
|
||||
serverMemberUpdateFrame.id.user
|
||||
)
|
||||
|
|
@ -706,12 +706,12 @@ object RealtimeSocket {
|
|||
|
||||
Log.d("RealtimeSocket", "Updated member: $updated")
|
||||
|
||||
RevoltAPI.members.setMember(serverMemberUpdateFrame.id.server, updated)
|
||||
PeptideAPI.members.setMember(serverMemberUpdateFrame.id.server, updated)
|
||||
}
|
||||
|
||||
"ServerMemberJoin" -> {
|
||||
val serverMemberJoinFrame =
|
||||
RevoltJson.decodeFromString(ServerMemberJoinFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ServerMemberJoinFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received server member join frame for ${serverMemberJoinFrame.user} in ${serverMemberJoinFrame.id}."
|
||||
|
|
@ -719,18 +719,18 @@ object RealtimeSocket {
|
|||
|
||||
val member = fetchMember(serverMemberJoinFrame.id, serverMemberJoinFrame.user)
|
||||
|
||||
RevoltAPI.members.setMember(serverMemberJoinFrame.id, member)
|
||||
PeptideAPI.members.setMember(serverMemberJoinFrame.id, member)
|
||||
}
|
||||
|
||||
"ServerMemberLeave" -> {
|
||||
val serverMemberLeaveFrame =
|
||||
RevoltJson.decodeFromString(ServerMemberLeaveFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ServerMemberLeaveFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received server member leave frame for ${serverMemberLeaveFrame.user} in ${serverMemberLeaveFrame.id}."
|
||||
)
|
||||
|
||||
RevoltAPI.members.removeMember(
|
||||
PeptideAPI.members.removeMember(
|
||||
serverMemberLeaveFrame.id,
|
||||
serverMemberLeaveFrame.user
|
||||
)
|
||||
|
|
@ -738,13 +738,13 @@ object RealtimeSocket {
|
|||
|
||||
"ServerRoleUpdate" -> {
|
||||
val serverRoleUpdateFrame =
|
||||
RevoltJson.decodeFromString(ServerRoleUpdateFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ServerRoleUpdateFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received server role update frame for ${serverRoleUpdateFrame.id}."
|
||||
)
|
||||
|
||||
val server = RevoltAPI.serverCache[serverRoleUpdateFrame.id]
|
||||
val server = PeptideAPI.serverCache[serverRoleUpdateFrame.id]
|
||||
if (server == null) {
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
|
|
@ -766,7 +766,7 @@ object RealtimeSocket {
|
|||
Pair(serverRoleUpdateFrame.roleId, newRole)
|
||||
) ?: mapOf(serverRoleUpdateFrame.roleId to newRole)
|
||||
)
|
||||
RevoltAPI.serverCache[serverRoleUpdateFrame.id] = newServer
|
||||
PeptideAPI.serverCache[serverRoleUpdateFrame.id] = newServer
|
||||
} else {
|
||||
// True role update.
|
||||
Log.d(
|
||||
|
|
@ -779,19 +779,19 @@ object RealtimeSocket {
|
|||
Pair(serverRoleUpdateFrame.roleId, updatedRole)
|
||||
)
|
||||
)
|
||||
RevoltAPI.serverCache[serverRoleUpdateFrame.id] = newServer
|
||||
PeptideAPI.serverCache[serverRoleUpdateFrame.id] = newServer
|
||||
}
|
||||
}
|
||||
|
||||
"ServerRoleDelete" -> {
|
||||
val serverRoleDeleteFrame =
|
||||
RevoltJson.decodeFromString(ServerRoleDeleteFrame.serializer(), rawFrame)
|
||||
PeptideJson.decodeFromString(ServerRoleDeleteFrame.serializer(), rawFrame)
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
"Received server role delete frame for ${serverRoleDeleteFrame.id} and role ${serverRoleDeleteFrame.roleId}."
|
||||
)
|
||||
|
||||
val server = RevoltAPI.serverCache[serverRoleDeleteFrame.id]
|
||||
val server = PeptideAPI.serverCache[serverRoleDeleteFrame.id]
|
||||
if (server == null) {
|
||||
Log.d(
|
||||
"RealtimeSocket",
|
||||
|
|
@ -803,7 +803,7 @@ object RealtimeSocket {
|
|||
val newRoles = server.roles?.toMutableMap() ?: mutableMapOf()
|
||||
newRoles.remove(serverRoleDeleteFrame.roleId)
|
||||
|
||||
RevoltAPI.serverCache[serverRoleDeleteFrame.id] =
|
||||
PeptideAPI.serverCache[serverRoleDeleteFrame.id] =
|
||||
server.copy(roles = newRoles)
|
||||
}
|
||||
|
||||
|
|
@ -819,7 +819,7 @@ object RealtimeSocket {
|
|||
}
|
||||
|
||||
private suspend fun pushReconnectEvent() {
|
||||
RevoltAPI.wsFrameChannel.send(RealtimeSocketFrames.Reconnected)
|
||||
PeptideAPI.wsFrameChannel.send(RealtimeSocketFrames.Reconnected)
|
||||
}
|
||||
|
||||
suspend fun beginTyping(channelId: String) {
|
||||
|
|
@ -827,7 +827,7 @@ object RealtimeSocket {
|
|||
|
||||
val beginTypingFrame = BeginTypingFrame("BeginTyping", channelId)
|
||||
socket?.send(
|
||||
RevoltJson.encodeToString(
|
||||
PeptideJson.encodeToString(
|
||||
BeginTypingFrame.serializer(),
|
||||
beginTypingFrame
|
||||
)
|
||||
|
|
@ -839,7 +839,7 @@ object RealtimeSocket {
|
|||
|
||||
val endTypingFrame = EndTypingFrame("EndTyping", channelId)
|
||||
socket?.send(
|
||||
RevoltJson.encodeToString(
|
||||
PeptideJson.encodeToString(
|
||||
EndTypingFrame.serializer(),
|
||||
endTypingFrame
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ package chat.peptide.api.routes.account
|
|||
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import io.ktor.client.request.post
|
||||
import io.ktor.client.request.setBody
|
||||
|
|
@ -104,22 +104,22 @@ data class EmailPasswordAssessment(
|
|||
val proceedMfa: Boolean = false,
|
||||
val mfaSpec: MfaLoginSpec? = null,
|
||||
val firstUserHints: UserHints? = null,
|
||||
val error: RevoltError? = null
|
||||
val error: PeptideError? = null
|
||||
)
|
||||
|
||||
suspend fun negotiateAuthentication(email: String, password: String): EmailPasswordAssessment {
|
||||
val sessionName = friendlySessionName()
|
||||
|
||||
val response: HttpResponse = RevoltHttp.post("/auth/session/login".api()) {
|
||||
val response: HttpResponse = PeptideHttp.post("/auth/session/login".api()) {
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(LoginNegotiation(email, password, sessionName, null))
|
||||
}
|
||||
|
||||
val responseContent = response.bodyAsText()
|
||||
Log.d("Revolt", "negotiateAuthentication: $responseContent")
|
||||
Log.d("Peptide", "negotiateAuthentication: $responseContent")
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), responseContent)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), responseContent)
|
||||
return EmailPasswordAssessment(error = error)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
|
|
@ -127,22 +127,22 @@ suspend fun negotiateAuthentication(email: String, password: String): EmailPassw
|
|||
|
||||
if (response.status == HttpStatusCode.InternalServerError) {
|
||||
return EmailPasswordAssessment(
|
||||
error = RevoltError(
|
||||
error = PeptideError(
|
||||
"InternalServerError"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val responseJson = RevoltJson.decodeFromString(MfaCheck.serializer(), responseContent)
|
||||
val responseJson = PeptideJson.decodeFromString(MfaCheck.serializer(), responseContent)
|
||||
|
||||
return when (responseJson.result) {
|
||||
"Success" -> EmailPasswordAssessment(
|
||||
firstUserHints = RevoltJson.decodeFromString(UserHints.serializer(), responseContent)
|
||||
firstUserHints = PeptideJson.decodeFromString(UserHints.serializer(), responseContent)
|
||||
)
|
||||
|
||||
"MFA" -> EmailPasswordAssessment(
|
||||
proceedMfa = true,
|
||||
mfaSpec = RevoltJson.decodeFromString(MfaLoginSpec.serializer(), responseContent)
|
||||
mfaSpec = PeptideJson.decodeFromString(MfaLoginSpec.serializer(), responseContent)
|
||||
)
|
||||
|
||||
else -> throw Exception("Unknown result: ${responseJson.result}")
|
||||
|
|
@ -153,23 +153,23 @@ suspend fun authenticateWithMfaTotpCode(
|
|||
mfaTicket: String,
|
||||
mfaResponse: MfaResponseTotpCode
|
||||
): EmailPasswordAssessment {
|
||||
val response: HttpResponse = RevoltHttp.post("/auth/session/login".api()) {
|
||||
val response: HttpResponse = PeptideHttp.post("/auth/session/login".api()) {
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(LoginMfaAmendmentTotpCode(mfaTicket, mfaResponse, friendlySessionName()))
|
||||
}
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response.bodyAsText())
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response.bodyAsText())
|
||||
return EmailPasswordAssessment(error = error)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
val responseContent = response.bodyAsText()
|
||||
Log.d("Revolt", "authenticateWithMfaTotpCode: $responseContent")
|
||||
Log.d("Peptide", "authenticateWithMfaTotpCode: $responseContent")
|
||||
|
||||
return EmailPasswordAssessment(
|
||||
firstUserHints = RevoltJson.decodeFromString(UserHints.serializer(), responseContent)
|
||||
firstUserHints = PeptideJson.decodeFromString(UserHints.serializer(), responseContent)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -177,26 +177,26 @@ suspend fun authenticateWithMfaRecoveryCode(
|
|||
mfaTicket: String,
|
||||
mfaResponse: MfaResponseRecoveryCode
|
||||
): EmailPasswordAssessment {
|
||||
val response: HttpResponse = RevoltHttp.post("/auth/session/login".api()) {
|
||||
val response: HttpResponse = PeptideHttp.post("/auth/session/login".api()) {
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(LoginMfaAmendmentRecoveryCode(mfaTicket, mfaResponse, friendlySessionName()))
|
||||
}
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response.bodyAsText())
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response.bodyAsText())
|
||||
return EmailPasswordAssessment(error = error)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
val responseContent = response.bodyAsText()
|
||||
Log.d("Revolt", "authenticateWithMfaRecoveryCode: $responseContent")
|
||||
Log.d("Peptide", "authenticateWithMfaRecoveryCode: $responseContent")
|
||||
|
||||
return EmailPasswordAssessment(
|
||||
firstUserHints = RevoltJson.decodeFromString(UserHints.serializer(), responseContent)
|
||||
firstUserHints = PeptideJson.decodeFromString(UserHints.serializer(), responseContent)
|
||||
)
|
||||
}
|
||||
|
||||
fun friendlySessionName(): String {
|
||||
return "Revolt Android on ${Build.MANUFACTURER} ${Build.MODEL}"
|
||||
return "Peptide Android on ${Build.MANUFACTURER} ${Build.MODEL}"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package chat.peptide.api.routes.account
|
||||
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.schemas.RsResult
|
||||
import chat.peptide.api.api
|
||||
import io.ktor.client.request.post
|
||||
|
|
@ -21,8 +21,8 @@ data class RegistrationBody(
|
|||
val captcha: String
|
||||
)
|
||||
|
||||
suspend fun register(body: RegistrationBody): RsResult<Unit, RevoltError> {
|
||||
val response = RevoltHttp.post("/auth/account/create".api()) {
|
||||
suspend fun register(body: RegistrationBody): RsResult<Unit, PeptideError> {
|
||||
val response = PeptideHttp.post("/auth/account/create".api()) {
|
||||
setBody(body)
|
||||
contentType(ContentType.Application.Json)
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ suspend fun register(body: RegistrationBody): RsResult<Unit, RevoltError> {
|
|||
val responseContent = response.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), responseContent)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), responseContent)
|
||||
return RsResult.err(error)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package chat.peptide.api.routes.auth
|
||||
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import chat.peptide.api.schemas.Session
|
||||
import io.ktor.client.request.delete
|
||||
|
|
@ -11,21 +11,21 @@ import io.ktor.client.statement.bodyAsText
|
|||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
||||
suspend fun fetchAllSessions(): List<Session> {
|
||||
val response = RevoltHttp.get("/auth/session/all".api())
|
||||
val response = PeptideHttp.get("/auth/session/all".api())
|
||||
.bodyAsText()
|
||||
|
||||
return RevoltJson.decodeFromString(
|
||||
return PeptideJson.decodeFromString(
|
||||
ListSerializer(Session.serializer()),
|
||||
response
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun logoutSessionById(id: String) {
|
||||
RevoltHttp.delete("/auth/session/$id".api())
|
||||
PeptideHttp.delete("/auth/session/$id".api())
|
||||
}
|
||||
|
||||
suspend fun logoutAllSessions(includingSelf: Boolean = false) {
|
||||
RevoltHttp.delete("/auth/session/all".api()) {
|
||||
PeptideHttp.delete("/auth/session/all".api()) {
|
||||
parameter("revoke_self", includingSelf)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package chat.peptide.api.routes.channel
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import chat.peptide.api.internals.ULID
|
||||
import chat.peptide.api.schemas.Channel
|
||||
|
|
@ -37,7 +37,7 @@ suspend fun fetchMessagesFromChannel(
|
|||
nearby: String? = null,
|
||||
sort: String? = null
|
||||
): MessagesInChannel {
|
||||
val response = RevoltHttp.get("/channels/$channelId/messages".api()) {
|
||||
val response = PeptideHttp.get("/channels/$channelId/messages".api()) {
|
||||
parameter("limit", limit)
|
||||
parameter("include_users", includeUsers)
|
||||
|
||||
|
|
@ -49,12 +49,12 @@ suspend fun fetchMessagesFromChannel(
|
|||
.bodyAsText()
|
||||
|
||||
if (includeUsers) {
|
||||
return RevoltJson.decodeFromString(
|
||||
return PeptideJson.decodeFromString(
|
||||
MessagesInChannel.serializer(),
|
||||
response
|
||||
)
|
||||
} else {
|
||||
val messages = RevoltJson.decodeFromString(
|
||||
val messages = PeptideJson.decodeFromString(
|
||||
ListSerializer(Message.serializer()),
|
||||
response
|
||||
)
|
||||
|
|
@ -104,7 +104,7 @@ suspend fun sendMessage(
|
|||
attachments: List<String>? = null,
|
||||
idempotencyKey: String = ULID.makeNext()
|
||||
): String {
|
||||
val response = RevoltHttp.post("/channels/$channelId/messages".api()) {
|
||||
val response = PeptideHttp.post("/channels/$channelId/messages".api()) {
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(
|
||||
SendMessageBody(
|
||||
|
|
@ -122,7 +122,7 @@ suspend fun sendMessage(
|
|||
}
|
||||
|
||||
suspend fun editMessage(channelId: String, messageId: String, newContent: String? = null) {
|
||||
val response = RevoltHttp.patch("/channels/$channelId/messages/$messageId".api()) {
|
||||
val response = PeptideHttp.patch("/channels/$channelId/messages/$messageId".api()) {
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(
|
||||
EditMessageBody(
|
||||
|
|
@ -133,7 +133,7 @@ suspend fun editMessage(channelId: String, messageId: String, newContent: String
|
|||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Error(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
|
|
@ -141,55 +141,55 @@ suspend fun editMessage(channelId: String, messageId: String, newContent: String
|
|||
}
|
||||
|
||||
suspend fun deleteMessage(channelId: String, messageId: String) {
|
||||
RevoltHttp.delete("/channels/$channelId/messages/$messageId".api())
|
||||
PeptideHttp.delete("/channels/$channelId/messages/$messageId".api())
|
||||
}
|
||||
|
||||
suspend fun ackChannel(channelId: String, messageId: String = ULID.makeNext()) {
|
||||
RevoltHttp.put("/channels/$channelId/ack/$messageId".api())
|
||||
PeptideHttp.put("/channels/$channelId/ack/$messageId".api())
|
||||
}
|
||||
|
||||
suspend fun fetchSingleChannel(channelId: String): Channel {
|
||||
val response = RevoltHttp.get("/channels/$channelId".api())
|
||||
val response = PeptideHttp.get("/channels/$channelId".api())
|
||||
.bodyAsText()
|
||||
|
||||
return RevoltJson.decodeFromString(
|
||||
return PeptideJson.decodeFromString(
|
||||
Channel.serializer(),
|
||||
response
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun fetchGroupParticipants(channelId: String): List<User> {
|
||||
val response = RevoltHttp.get("/channels/$channelId/members".api())
|
||||
val response = PeptideHttp.get("/channels/$channelId/members".api())
|
||||
.bodyAsText()
|
||||
|
||||
return RevoltJson.decodeFromString(
|
||||
return PeptideJson.decodeFromString(
|
||||
ListSerializer(User.serializer()),
|
||||
response
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun createInvite(channelId: String): CreateInviteResponse {
|
||||
val response = RevoltHttp.post("/channels/$channelId/invites".api())
|
||||
val response = PeptideHttp.post("/channels/$channelId/invites".api())
|
||||
.bodyAsText()
|
||||
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
if (error.type != "Server") throw Error(error.type)
|
||||
|
||||
return RevoltJson.decodeFromString(CreateInviteResponse.serializer(), response)
|
||||
return PeptideJson.decodeFromString(CreateInviteResponse.serializer(), response)
|
||||
}
|
||||
|
||||
suspend fun fetchSingleMessage(channelId: String, messageId: String): Message {
|
||||
val response = RevoltHttp.get("/channels/$channelId/messages/$messageId".api())
|
||||
val response = PeptideHttp.get("/channels/$channelId/messages/$messageId".api())
|
||||
.bodyAsText()
|
||||
|
||||
return RevoltJson.decodeFromString(
|
||||
return PeptideJson.decodeFromString(
|
||||
Message.serializer(),
|
||||
response
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun leaveDeleteOrCloseChannel(channelId: String, leaveSilently: Boolean = false) {
|
||||
RevoltHttp.delete("/channels/$channelId".api()) {
|
||||
PeptideHttp.delete("/channels/$channelId".api()) {
|
||||
parameter("leave_silently", leaveSilently)
|
||||
}
|
||||
}
|
||||
|
|
@ -207,33 +207,33 @@ suspend fun patchChannel(
|
|||
val body = mutableMapOf<String, JsonElement>()
|
||||
|
||||
if (name != null) {
|
||||
body["name"] = RevoltJson.encodeToJsonElement(String.serializer(), name)
|
||||
body["name"] = PeptideJson.encodeToJsonElement(String.serializer(), name)
|
||||
}
|
||||
|
||||
if (description != null) {
|
||||
body["description"] = RevoltJson.encodeToJsonElement(String.serializer(), description)
|
||||
body["description"] = PeptideJson.encodeToJsonElement(String.serializer(), description)
|
||||
}
|
||||
|
||||
if (icon != null) {
|
||||
body["icon"] = RevoltJson.encodeToJsonElement(String.serializer(), icon)
|
||||
body["icon"] = PeptideJson.encodeToJsonElement(String.serializer(), icon)
|
||||
}
|
||||
|
||||
if (banner != null) {
|
||||
body["banner"] = RevoltJson.encodeToJsonElement(String.serializer(), banner)
|
||||
body["banner"] = PeptideJson.encodeToJsonElement(String.serializer(), banner)
|
||||
}
|
||||
|
||||
if (remove != null) {
|
||||
body["remove"] = RevoltJson.encodeToJsonElement(ListSerializer(String.serializer()), remove)
|
||||
body["remove"] = PeptideJson.encodeToJsonElement(ListSerializer(String.serializer()), remove)
|
||||
}
|
||||
|
||||
if (nsfw != null) {
|
||||
body["nsfw"] = RevoltJson.encodeToJsonElement(Boolean.serializer(), nsfw)
|
||||
body["nsfw"] = PeptideJson.encodeToJsonElement(Boolean.serializer(), nsfw)
|
||||
}
|
||||
|
||||
val response = RevoltHttp.patch("/channels/$channelId".api()) {
|
||||
val response = PeptideHttp.patch("/channels/$channelId".api()) {
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(
|
||||
RevoltJson.encodeToString(
|
||||
PeptideJson.encodeToString(
|
||||
MapSerializer(
|
||||
String.serializer(),
|
||||
JsonElement.serializer()
|
||||
|
|
@ -245,14 +245,14 @@ suspend fun patchChannel(
|
|||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Exception(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
if (!pure) {
|
||||
val channel = RevoltJson.decodeFromString(Channel.serializer(), response)
|
||||
RevoltAPI.channelCache[channelId] = channel
|
||||
val channel = PeptideJson.decodeFromString(Channel.serializer(), response)
|
||||
PeptideAPI.channelCache[channelId] = channel
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package chat.peptide.api.routes.channel
|
||||
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import chat.peptide.api.schemas.Channel
|
||||
import chat.peptide.screens.create.MAX_ADDABLE_PEOPLE_IN_GROUP
|
||||
|
|
@ -28,23 +28,23 @@ suspend fun createGroupDM(name: String, members: List<String>): Channel {
|
|||
throw Exception("Too many members, maximum is $MAX_ADDABLE_PEOPLE_IN_GROUP")
|
||||
}
|
||||
|
||||
val response = RevoltHttp.post("/channels/create".api()) {
|
||||
val response = PeptideHttp.post("/channels/create".api()) {
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(CreateGroupDMBody(name, members))
|
||||
}.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Error(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
return RevoltJson.decodeFromString(Channel.serializer(), response)
|
||||
return PeptideJson.decodeFromString(Channel.serializer(), response)
|
||||
}
|
||||
|
||||
suspend fun removeMember(channelId: String, userId: String) {
|
||||
val response = RevoltHttp.delete("/channels/$channelId/recipients/$userId".api())
|
||||
val response = PeptideHttp.delete("/channels/$channelId/recipients/$userId".api())
|
||||
|
||||
if (!response.status.isSuccess()) {
|
||||
throw Error(response.status.toString())
|
||||
|
|
@ -52,7 +52,7 @@ suspend fun removeMember(channelId: String, userId: String) {
|
|||
}
|
||||
|
||||
suspend fun addMember(channelId: String, userId: String) {
|
||||
val response = RevoltHttp.put("/channels/$channelId/recipients/$userId".api())
|
||||
val response = PeptideHttp.put("/channels/$channelId/recipients/$userId".api())
|
||||
|
||||
if (!response.status.isSuccess()) {
|
||||
throw Error(response.status.toString())
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
package chat.peptide.api.routes.channel
|
||||
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.api
|
||||
import io.ktor.client.request.delete
|
||||
import io.ktor.client.request.put
|
||||
|
||||
suspend fun react(channelId: String, messageId: String, emoji: String) {
|
||||
RevoltHttp.put("/channels/$channelId/messages/$messageId/reactions/$emoji".api())
|
||||
PeptideHttp.put("/channels/$channelId/messages/$messageId/reactions/$emoji".api())
|
||||
}
|
||||
|
||||
suspend fun unreact(channelId: String, messageId: String, emoji: String) {
|
||||
RevoltHttp.delete("/channels/$channelId/messages/$messageId/reactions/$emoji".api())
|
||||
PeptideHttp.delete("/channels/$channelId/messages/$messageId/reactions/$emoji".api())
|
||||
}
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
package chat.peptide.api.routes.custom
|
||||
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import chat.peptide.api.schemas.Emoji
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.statement.bodyAsText
|
||||
|
||||
suspend fun fetchEmoji(id: String): Emoji {
|
||||
val response = RevoltHttp.get("/custom/emoji/$id".api()).bodyAsText()
|
||||
return RevoltJson.decodeFromString(
|
||||
val response = PeptideHttp.get("/custom/emoji/$id".api()).bodyAsText()
|
||||
return PeptideJson.decodeFromString(
|
||||
Emoji.serializer(),
|
||||
response
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package chat.peptide.api.routes.googlesheets
|
||||
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.statement.bodyAsText
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
|
@ -27,7 +27,7 @@ object GoogleSheetsService {
|
|||
crossinline mapper: (Map<String, String>) -> T
|
||||
): List<T> = withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val response = RevoltHttp.get(sheetUrl).bodyAsText()
|
||||
val response = PeptideHttp.get(sheetUrl).bodyAsText()
|
||||
|
||||
// Determine if the response is CSV or JSON
|
||||
if (sheetUrl.contains("output=csv") || response.startsWith("\"") || response.contains(",")) {
|
||||
|
|
@ -104,7 +104,7 @@ object GoogleSheetsService {
|
|||
jsonData: String,
|
||||
crossinline mapper: (Map<String, String>) -> T
|
||||
): List<T> {
|
||||
val sheetResponse = RevoltJson.decodeFromString<GoogleSheetResponse>(jsonData)
|
||||
val sheetResponse = PeptideJson.decodeFromString<GoogleSheetResponse>(jsonData)
|
||||
|
||||
// Convert the sheet data to a list of objects
|
||||
val headers = sheetResponse.feed.entry
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package chat.peptide.api.routes.invites
|
||||
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import chat.peptide.api.schemas.Invite
|
||||
import chat.peptide.api.schemas.InviteJoined
|
||||
|
|
@ -12,32 +12,32 @@ import io.ktor.client.request.post
|
|||
import io.ktor.client.statement.bodyAsText
|
||||
import kotlinx.serialization.SerializationException
|
||||
|
||||
suspend fun fetchInviteByCode(code: String): RsResult<Invite, RevoltError> {
|
||||
val response = RevoltHttp.get("/invites/$code".api())
|
||||
suspend fun fetchInviteByCode(code: String): RsResult<Invite, PeptideError> {
|
||||
val response = PeptideHttp.get("/invites/$code".api())
|
||||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
if (error.type != "Server") return RsResult.err(error)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
val invite = RevoltJson.decodeFromString(Invite.serializer(), response)
|
||||
val invite = PeptideJson.decodeFromString(Invite.serializer(), response)
|
||||
return RsResult.ok(invite)
|
||||
}
|
||||
|
||||
suspend fun joinInviteByCode(code: String): RsResult<InviteJoined, RevoltError> {
|
||||
val response = RevoltHttp.post("/invites/$code".api())
|
||||
suspend fun joinInviteByCode(code: String): RsResult<InviteJoined, PeptideError> {
|
||||
val response = PeptideHttp.post("/invites/$code".api())
|
||||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
if (error.type != "Server") return RsResult.err(error)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
val invite = RevoltJson.decodeFromString(InviteJoined.serializer(), response)
|
||||
val invite = PeptideJson.decodeFromString(InviteJoined.serializer(), response)
|
||||
return RsResult.ok(invite)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package chat.peptide.api.routes.microservices.autumn
|
||||
|
||||
import chat.peptide.api.HitRateLimitException
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.schemas.AutumnError
|
||||
import chat.peptide.api.schemas.AutumnId
|
||||
import io.ktor.client.plugins.onUpload
|
||||
|
|
@ -36,9 +36,9 @@ suspend fun uploadToAutumn(
|
|||
contentType: ContentType,
|
||||
onProgress: (Long, Long) -> Unit = { _, _ -> }
|
||||
): String {
|
||||
val uploadUrl = "${RevoltAPI.getCurrentFilesUrl()}/$tag"
|
||||
val uploadUrl = "${PeptideAPI.getCurrentFilesUrl()}/$tag"
|
||||
|
||||
val response = RevoltHttp.post(uploadUrl) {
|
||||
val response = PeptideHttp.post(uploadUrl) {
|
||||
setBody(
|
||||
MultiPartFormDataContent(
|
||||
formData {
|
||||
|
|
@ -53,18 +53,18 @@ suspend fun uploadToAutumn(
|
|||
}
|
||||
)
|
||||
)
|
||||
header(RevoltAPI.TOKEN_HEADER_NAME, RevoltAPI.sessionToken)
|
||||
header(PeptideAPI.TOKEN_HEADER_NAME, PeptideAPI.sessionToken)
|
||||
onUpload { bytesSentTotal, contentLength ->
|
||||
contentLength?.let { onProgress(bytesSentTotal, it) }
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
val autumnId = RevoltJson.decodeFromString(AutumnId.serializer(), response.bodyAsText())
|
||||
val autumnId = PeptideJson.decodeFromString(AutumnId.serializer(), response.bodyAsText())
|
||||
return autumnId.id
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(AutumnError.serializer(), response.bodyAsText())
|
||||
val error = PeptideJson.decodeFromString(AutumnError.serializer(), response.bodyAsText())
|
||||
throw Exception(error.type)
|
||||
} catch (e: Exception) {
|
||||
if (response.status == HttpStatusCode.TooManyRequests) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package chat.peptide.api.routes.microservices.geo
|
||||
|
||||
import chat.peptide.api.HitRateLimitException
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.buildUserAgent
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.request.header
|
||||
|
|
@ -18,12 +18,12 @@ data class GeoResponse(
|
|||
|
||||
suspend fun queryGeo(): GeoResponse {
|
||||
try {
|
||||
val response = RevoltHttp.get("https://geo.revolt.chat/?client=android") {
|
||||
val response = PeptideHttp.get("https://geo.peptide.chat/?client=android") {
|
||||
header("User-Agent", buildUserAgent("Ktor queryGeo"))
|
||||
}
|
||||
|
||||
if (response.status == HttpStatusCode.OK) {
|
||||
return RevoltJson.decodeFromString(response.bodyAsText())
|
||||
return PeptideJson.decodeFromString(response.bodyAsText())
|
||||
} else throw Exception("Failed to query geo: ${response.status.value} ${response.status.description}")
|
||||
} catch (e: Exception) {
|
||||
throw Exception("Failed to query geo: ${e.message}", e).also {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package chat.peptide.api.routes.microservices.health
|
||||
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.schemas.HealthNotice
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.statement.bodyAsText
|
||||
|
||||
suspend fun healthCheck(): HealthNotice {
|
||||
val response = RevoltHttp.get("https://health.revolt.chat/api/health").bodyAsText()
|
||||
return RevoltJson.decodeFromString(HealthNotice.serializer(), response)
|
||||
val response = PeptideHttp.get("https://health.peptide.chat/api/health").bodyAsText()
|
||||
return PeptideJson.decodeFromString(HealthNotice.serializer(), response)
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package chat.peptide.api.routes.microservices.january
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import java.net.URLEncoder
|
||||
|
||||
fun asJanuaryProxyUrl(url: String): String {
|
||||
return "${RevoltAPI.getCurrentJanuaryUrl()}/proxy?url=${URLEncoder.encode(url, "utf-8")}"
|
||||
return "${PeptideAPI.getCurrentJanuaryUrl()}/proxy?url=${URLEncoder.encode(url, "utf-8")}"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package chat.peptide.api.routes.misc
|
||||
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.api
|
||||
import io.ktor.client.call.body
|
||||
import io.ktor.client.request.get
|
||||
|
|
@ -9,7 +9,7 @@ import kotlinx.serialization.Serializable
|
|||
|
||||
@Serializable
|
||||
data class Root(
|
||||
val revolt: String,
|
||||
val peptide: String,
|
||||
val features: Features,
|
||||
val ws: String,
|
||||
val app: String,
|
||||
|
|
@ -61,5 +61,5 @@ data class LiveKitNode(
|
|||
)
|
||||
|
||||
suspend fun getRootRoute(): Root {
|
||||
return RevoltHttp.get("/".api()).body()
|
||||
return PeptideHttp.get("/".api()).body()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package chat.peptide.api.routes.onboard
|
||||
|
||||
import chat.peptide.api.RateLimitResponse
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import chat.peptide.api.schemas.RsResult
|
||||
import io.ktor.client.request.get
|
||||
|
|
@ -23,22 +23,22 @@ data class OnboardingResponse(
|
|||
val onboarding: Boolean
|
||||
)
|
||||
|
||||
suspend fun needsOnboarding(sessionToken: String = RevoltAPI.sessionToken): Boolean {
|
||||
val response = RevoltHttp.get("/onboard/hello".api()) {
|
||||
header(RevoltAPI.TOKEN_HEADER_NAME, sessionToken)
|
||||
suspend fun needsOnboarding(sessionToken: String = PeptideAPI.sessionToken): Boolean {
|
||||
val response = PeptideHttp.get("/onboard/hello".api()) {
|
||||
header(PeptideAPI.TOKEN_HEADER_NAME, sessionToken)
|
||||
}
|
||||
|
||||
val responseContent = response.bodyAsText()
|
||||
|
||||
try {
|
||||
val rateLimitResponse =
|
||||
RevoltJson.decodeFromString(RateLimitResponse.serializer(), responseContent)
|
||||
PeptideJson.decodeFromString(RateLimitResponse.serializer(), responseContent)
|
||||
throw rateLimitResponse.toException()
|
||||
} catch (e: SerializationException) {
|
||||
// good path
|
||||
}
|
||||
|
||||
return RevoltJson.decodeFromString(OnboardingResponse.serializer(), responseContent).onboarding
|
||||
return PeptideJson.decodeFromString(OnboardingResponse.serializer(), responseContent).onboarding
|
||||
}
|
||||
|
||||
@Serializable
|
||||
|
|
@ -48,26 +48,26 @@ data class OnboardingCompletionBody(
|
|||
|
||||
suspend fun completeOnboarding(
|
||||
body: OnboardingCompletionBody,
|
||||
sessionToken: String = RevoltAPI.sessionToken
|
||||
): RsResult<Unit, RevoltError> {
|
||||
val response = RevoltHttp.post("/onboard/complete".api()) {
|
||||
sessionToken: String = PeptideAPI.sessionToken
|
||||
): RsResult<Unit, PeptideError> {
|
||||
val response = PeptideHttp.post("/onboard/complete".api()) {
|
||||
setBody(body)
|
||||
contentType(ContentType.Application.Json)
|
||||
header(RevoltAPI.TOKEN_HEADER_NAME, sessionToken)
|
||||
header(PeptideAPI.TOKEN_HEADER_NAME, sessionToken)
|
||||
}
|
||||
|
||||
if (response.status == HttpStatusCode.Conflict) {
|
||||
return RsResult.err(RevoltError("UsernameTaken"))
|
||||
return RsResult.err(PeptideError("UsernameTaken"))
|
||||
}
|
||||
|
||||
if (response.status == HttpStatusCode.BadRequest) {
|
||||
return RsResult.err(RevoltError("InvalidUsername"))
|
||||
return RsResult.err(PeptideError("InvalidUsername"))
|
||||
}
|
||||
|
||||
val responseContent = response.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), responseContent)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), responseContent)
|
||||
return RsResult.err(error)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package chat.peptide.api.routes.push
|
||||
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.routes.account.WebPushData
|
||||
import chat.peptide.api.api
|
||||
import io.ktor.client.request.post
|
||||
|
|
@ -19,7 +19,7 @@ suspend fun subscribePush(
|
|||
auth = auth
|
||||
)
|
||||
|
||||
RevoltHttp.post("/push/subscribe".api()) {
|
||||
PeptideHttp.post("/push/subscribe".api()) {
|
||||
setBody(data)
|
||||
contentType(ContentType.Application.Json)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package chat.peptide.api.routes.safety
|
||||
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.schemas.ContentReportReason
|
||||
import chat.peptide.api.schemas.FullMessageReport
|
||||
import chat.peptide.api.schemas.FullServerReport
|
||||
|
|
@ -31,9 +31,9 @@ suspend fun putMessageReport(
|
|||
additional_context = additionalContext
|
||||
)
|
||||
|
||||
val response = RevoltHttp.post("/safety/report".api()) {
|
||||
val response = PeptideHttp.post("/safety/report".api()) {
|
||||
setBody(
|
||||
RevoltJson.encodeToString(
|
||||
PeptideJson.encodeToString(
|
||||
FullMessageReport.serializer(),
|
||||
fullMessageReport
|
||||
)
|
||||
|
|
@ -42,7 +42,7 @@ suspend fun putMessageReport(
|
|||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Error(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
|
|
@ -63,9 +63,9 @@ suspend fun putServerReport(
|
|||
additional_context = additionalContext
|
||||
)
|
||||
|
||||
val response = RevoltHttp.post("/safety/report".api()) {
|
||||
val response = PeptideHttp.post("/safety/report".api()) {
|
||||
setBody(
|
||||
RevoltJson.encodeToString(
|
||||
PeptideJson.encodeToString(
|
||||
FullServerReport.serializer(),
|
||||
fullServerReport
|
||||
)
|
||||
|
|
@ -74,7 +74,7 @@ suspend fun putServerReport(
|
|||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Error(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
|
|
@ -95,9 +95,9 @@ suspend fun putUserReport(
|
|||
additional_context = additionalContext
|
||||
)
|
||||
|
||||
val response = RevoltHttp.post("/safety/report".api()) {
|
||||
val response = PeptideHttp.post("/safety/report".api()) {
|
||||
setBody(
|
||||
RevoltJson.encodeToString(
|
||||
PeptideJson.encodeToString(
|
||||
FullUserReport.serializer(),
|
||||
fullUserReport
|
||||
)
|
||||
|
|
@ -106,7 +106,7 @@ suspend fun putUserReport(
|
|||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Error(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package chat.peptide.api.routes.server
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import chat.peptide.api.schemas.Member
|
||||
import chat.peptide.api.schemas.ServerWithChannelObjects
|
||||
|
|
@ -25,7 +25,7 @@ data class FetchMembersResponse(
|
|||
)
|
||||
|
||||
suspend fun ackServer(serverId: String) {
|
||||
RevoltHttp.put("/servers/$serverId/ack".api())
|
||||
PeptideHttp.put("/servers/$serverId/ack".api())
|
||||
}
|
||||
|
||||
suspend fun fetchMembers(
|
||||
|
|
@ -33,55 +33,55 @@ suspend fun fetchMembers(
|
|||
includeOffline: Boolean = false,
|
||||
pure: Boolean = false
|
||||
): FetchMembersResponse {
|
||||
val response = RevoltHttp.get("/servers/$serverId/members".api()) {
|
||||
val response = PeptideHttp.get("/servers/$serverId/members".api()) {
|
||||
parameter("exclude_offline", !includeOffline)
|
||||
}
|
||||
|
||||
val responseContent = response.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), responseContent)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), responseContent)
|
||||
throw Error(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
val membersResponse =
|
||||
RevoltJson.decodeFromString(FetchMembersResponse.serializer(), responseContent)
|
||||
PeptideJson.decodeFromString(FetchMembersResponse.serializer(), responseContent)
|
||||
|
||||
if (pure) {
|
||||
return membersResponse
|
||||
}
|
||||
|
||||
membersResponse.members.forEach { member ->
|
||||
if (!RevoltAPI.members.hasMember(serverId, member.id!!.user)) {
|
||||
RevoltAPI.members.setMember(serverId, member)
|
||||
if (!PeptideAPI.members.hasMember(serverId, member.id!!.user)) {
|
||||
PeptideAPI.members.setMember(serverId, member)
|
||||
}
|
||||
}
|
||||
|
||||
membersResponse.users.forEach { user ->
|
||||
user.id?.let { RevoltAPI.userCache.putIfAbsent(it, user) }
|
||||
user.id?.let { PeptideAPI.userCache.putIfAbsent(it, user) }
|
||||
}
|
||||
|
||||
return membersResponse
|
||||
}
|
||||
|
||||
suspend fun fetchMember(serverId: String, userId: String, pure: Boolean = false): Member {
|
||||
val response = RevoltHttp.get("/servers/$serverId/members/$userId".api())
|
||||
val response = PeptideHttp.get("/servers/$serverId/members/$userId".api())
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response.bodyAsText())
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response.bodyAsText())
|
||||
throw Exception(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
val member = RevoltJson.decodeFromString(Member.serializer(), response.bodyAsText())
|
||||
val member = PeptideJson.decodeFromString(Member.serializer(), response.bodyAsText())
|
||||
|
||||
if (!pure) {
|
||||
member.id?.let {
|
||||
if (!RevoltAPI.members.hasMember(serverId, it.user)) {
|
||||
RevoltAPI.members.setMember(serverId, member)
|
||||
if (!PeptideAPI.members.hasMember(serverId, it.user)) {
|
||||
PeptideAPI.members.setMember(serverId, member)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ suspend fun fetchMember(serverId: String, userId: String, pure: Boolean = false)
|
|||
}
|
||||
|
||||
suspend fun leaveOrDeleteServer(serverId: String, leaveSilently: Boolean = false) {
|
||||
RevoltHttp.delete("/servers/$serverId".api()) {
|
||||
PeptideHttp.delete("/servers/$serverId".api()) {
|
||||
parameter("leave_silently", leaveSilently)
|
||||
}
|
||||
}
|
||||
|
|
@ -109,16 +109,16 @@ suspend fun createServer(
|
|||
): ServerWithChannelObjects {
|
||||
val body = ServerCreationBody(name, description, nsfw)
|
||||
|
||||
val response = RevoltHttp.post("/servers/create".api()) {
|
||||
setBody(RevoltJson.encodeToString(ServerCreationBody.serializer(), body))
|
||||
val response = PeptideHttp.post("/servers/create".api()) {
|
||||
setBody(PeptideJson.encodeToString(ServerCreationBody.serializer(), body))
|
||||
}
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response.bodyAsText())
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response.bodyAsText())
|
||||
throw Exception(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
return RevoltJson.decodeFromString(ServerWithChannelObjects.serializer(), response.bodyAsText())
|
||||
return PeptideJson.decodeFromString(ServerWithChannelObjects.serializer(), response.bodyAsText())
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package chat.peptide.api.routes.sync
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import io.ktor.client.request.parameter
|
||||
import io.ktor.client.request.post
|
||||
|
|
@ -17,13 +17,13 @@ import kotlinx.serialization.json.JsonArray
|
|||
@Serializable
|
||||
data class SyncedSetting(val timestamp: Long, val value: String)
|
||||
|
||||
suspend fun getKeys(vararg keys: String, revoltToken: String): Map<String, SyncedSetting> {
|
||||
val response = RevoltHttp.post("/sync/settings/fetch".api()) {
|
||||
headers.append(RevoltAPI.TOKEN_HEADER_NAME, revoltToken)
|
||||
suspend fun getKeys(vararg keys: String, peptideToken: String): Map<String, SyncedSetting> {
|
||||
val response = PeptideHttp.post("/sync/settings/fetch".api()) {
|
||||
headers.append(PeptideAPI.TOKEN_HEADER_NAME, peptideToken)
|
||||
|
||||
// format: {"keys": ["key1", "key2"]}
|
||||
setBody(
|
||||
RevoltJson.encodeToString(
|
||||
PeptideJson.encodeToString(
|
||||
MapSerializer(
|
||||
String.serializer(),
|
||||
ListSerializer(String.serializer())
|
||||
|
|
@ -33,7 +33,7 @@ suspend fun getKeys(vararg keys: String, revoltToken: String): Map<String, Synce
|
|||
)
|
||||
}.bodyAsText()
|
||||
|
||||
return RevoltJson.decodeFromString(
|
||||
return PeptideJson.decodeFromString(
|
||||
MapSerializer(
|
||||
String.serializer(),
|
||||
JsonArray.serializer()
|
||||
|
|
@ -46,22 +46,22 @@ suspend fun getKeys(vararg keys: String, revoltToken: String): Map<String, Synce
|
|||
.toString()
|
||||
.removeSurrounding("\"")
|
||||
.replace("\\\"", "\"")
|
||||
.replace("\\\\", "\\") // the revolt API is so scuffed i can't even make this up
|
||||
.replace("\\\\", "\\") // the peptide API is so scuffed i can't even make this up
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getKeys(vararg keys: String): Map<String, SyncedSetting> {
|
||||
return getKeys(*keys, revoltToken = RevoltAPI.sessionToken)
|
||||
return getKeys(*keys, peptideToken = PeptideAPI.sessionToken)
|
||||
}
|
||||
|
||||
suspend fun setKey(key: String, value: String) {
|
||||
RevoltHttp.post("/sync/settings/set".api()) {
|
||||
PeptideHttp.post("/sync/settings/set".api()) {
|
||||
parameter("timestamp", System.currentTimeMillis())
|
||||
|
||||
// format: {"key": "value"}
|
||||
setBody(
|
||||
RevoltJson.encodeToString(
|
||||
PeptideJson.encodeToString(
|
||||
MapSerializer(
|
||||
String.serializer(),
|
||||
String.serializer()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package chat.peptide.api.routes.sync
|
||||
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import chat.peptide.api.schemas.ChannelUnreadResponse
|
||||
import io.ktor.client.request.get
|
||||
|
|
@ -9,10 +9,10 @@ import io.ktor.client.statement.bodyAsText
|
|||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
||||
suspend fun syncUnreads(): List<ChannelUnreadResponse> {
|
||||
val response = RevoltHttp.get("/sync/unreads".api())
|
||||
val response = PeptideHttp.get("/sync/unreads".api())
|
||||
.bodyAsText()
|
||||
|
||||
return RevoltJson.decodeFromString(
|
||||
return PeptideJson.decodeFromString(
|
||||
ListSerializer(ChannelUnreadResponse.serializer()),
|
||||
response
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package chat.peptide.api.routes.user
|
||||
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import chat.peptide.api.schemas.Channel
|
||||
import io.ktor.client.request.get
|
||||
|
|
@ -10,15 +10,15 @@ import io.ktor.client.statement.bodyAsText
|
|||
import kotlinx.serialization.SerializationException
|
||||
|
||||
suspend fun openDM(userId: String): Channel {
|
||||
val response = RevoltHttp.get("/users/$userId/dm".api())
|
||||
val response = PeptideHttp.get("/users/$userId/dm".api())
|
||||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Error(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
return RevoltJson.decodeFromString(Channel.serializer(), response)
|
||||
return PeptideJson.decodeFromString(Channel.serializer(), response)
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package chat.peptide.api.routes.user
|
||||
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import io.ktor.client.request.delete
|
||||
import io.ktor.client.request.post
|
||||
|
|
@ -14,11 +14,11 @@ import io.ktor.http.contentType
|
|||
import kotlinx.serialization.SerializationException
|
||||
|
||||
suspend fun blockUser(userId: String) {
|
||||
val response = RevoltHttp.put("/users/$userId/block".api())
|
||||
val response = PeptideHttp.put("/users/$userId/block".api())
|
||||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Exception(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
|
|
@ -26,11 +26,11 @@ suspend fun blockUser(userId: String) {
|
|||
}
|
||||
|
||||
suspend fun unblockUser(userId: String) {
|
||||
val response = RevoltHttp.delete("/users/$userId/block".api())
|
||||
val response = PeptideHttp.delete("/users/$userId/block".api())
|
||||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Exception(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
|
|
@ -38,14 +38,14 @@ suspend fun unblockUser(userId: String) {
|
|||
}
|
||||
|
||||
suspend fun friendUser(username: String) {
|
||||
val response = RevoltHttp.post("/users/friend".api()) {
|
||||
val response = PeptideHttp.post("/users/friend".api()) {
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(mapOf("username" to username))
|
||||
}
|
||||
val body = response.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), body)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), body)
|
||||
throw Exception(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
|
|
@ -53,11 +53,11 @@ suspend fun friendUser(username: String) {
|
|||
}
|
||||
|
||||
suspend fun acceptFriendRequest(userId: String) {
|
||||
val response = RevoltHttp.put("/users/$userId/friend".api())
|
||||
val response = PeptideHttp.put("/users/$userId/friend".api())
|
||||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Exception(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
|
|
@ -65,11 +65,11 @@ suspend fun acceptFriendRequest(userId: String) {
|
|||
}
|
||||
|
||||
suspend fun unfriendUser(userId: String) {
|
||||
val response = RevoltHttp.delete("/users/$userId/friend".api())
|
||||
val response = PeptideHttp.delete("/users/$userId/friend".api())
|
||||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Exception(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package chat.peptide.api.routes.user
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import chat.peptide.api.schemas.Profile
|
||||
import chat.peptide.api.schemas.Status
|
||||
|
|
@ -21,24 +21,24 @@ import kotlinx.serialization.builtins.serializer
|
|||
import kotlinx.serialization.json.JsonElement
|
||||
|
||||
suspend fun fetchSelf(): User {
|
||||
val response = RevoltHttp.get("/users/@me".api())
|
||||
val response = PeptideHttp.get("/users/@me".api())
|
||||
.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Exception(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
val user = RevoltJson.decodeFromString(User.serializer(), response)
|
||||
val user = PeptideJson.decodeFromString(User.serializer(), response)
|
||||
|
||||
if (user.id == null) {
|
||||
throw Exception("Self user ID is null")
|
||||
}
|
||||
|
||||
RevoltAPI.userCache[user.id] = user
|
||||
RevoltAPI.selfId = user.id
|
||||
PeptideAPI.userCache[user.id] = user
|
||||
PeptideAPI.selfId = user.id
|
||||
|
||||
return user
|
||||
}
|
||||
|
|
@ -54,11 +54,11 @@ suspend fun patchSelf(
|
|||
val body = mutableMapOf<String, JsonElement>()
|
||||
|
||||
if (status != null) {
|
||||
body["status"] = RevoltJson.encodeToJsonElement(Status.serializer(), status)
|
||||
body["status"] = PeptideJson.encodeToJsonElement(Status.serializer(), status)
|
||||
}
|
||||
|
||||
if (avatar != null) {
|
||||
body["avatar"] = RevoltJson.encodeToJsonElement(String.serializer(), avatar)
|
||||
body["avatar"] = PeptideJson.encodeToJsonElement(String.serializer(), avatar)
|
||||
}
|
||||
|
||||
if (background != null || bio != null) {
|
||||
|
|
@ -71,7 +71,7 @@ suspend fun patchSelf(
|
|||
profileMap["content"] = bio
|
||||
}
|
||||
|
||||
body["profile"] = RevoltJson.encodeToJsonElement(
|
||||
body["profile"] = PeptideJson.encodeToJsonElement(
|
||||
MapSerializer(
|
||||
String.serializer(),
|
||||
String.serializer()
|
||||
|
|
@ -81,13 +81,13 @@ suspend fun patchSelf(
|
|||
}
|
||||
|
||||
if (remove != null) {
|
||||
body["remove"] = RevoltJson.encodeToJsonElement(ListSerializer(String.serializer()), remove)
|
||||
body["remove"] = PeptideJson.encodeToJsonElement(ListSerializer(String.serializer()), remove)
|
||||
}
|
||||
|
||||
val response = RevoltHttp.patch("/users/@me".api()) {
|
||||
val response = PeptideHttp.patch("/users/@me".api()) {
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(
|
||||
RevoltJson.encodeToString(
|
||||
PeptideJson.encodeToString(
|
||||
MapSerializer(
|
||||
String.serializer(),
|
||||
JsonElement.serializer()
|
||||
|
|
@ -98,21 +98,21 @@ suspend fun patchSelf(
|
|||
}
|
||||
.bodyAsText()
|
||||
|
||||
if (RevoltAPI.selfId == null) {
|
||||
if (PeptideAPI.selfId == null) {
|
||||
throw Error("Self ID is null")
|
||||
}
|
||||
|
||||
val currentUser = RevoltAPI.userCache[RevoltAPI.selfId] ?: fetchSelf()
|
||||
val newUserKeys = RevoltJson.decodeFromString(User.serializer(), response)
|
||||
val currentUser = PeptideAPI.userCache[PeptideAPI.selfId] ?: fetchSelf()
|
||||
val newUserKeys = PeptideJson.decodeFromString(User.serializer(), response)
|
||||
val mergedUser = currentUser.mergeWithPartial(newUserKeys)
|
||||
|
||||
if (!pure) {
|
||||
RevoltAPI.userCache[RevoltAPI.selfId!!] = mergedUser
|
||||
PeptideAPI.userCache[PeptideAPI.selfId!!] = mergedUser
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun fetchUser(id: String): User {
|
||||
val res = RevoltHttp.get("/users/$id".api())
|
||||
val res = PeptideHttp.get("/users/$id".api())
|
||||
|
||||
if (res.status.value == 404) {
|
||||
return User.getPlaceholder(id)
|
||||
|
|
@ -121,42 +121,42 @@ suspend fun fetchUser(id: String): User {
|
|||
val response = res.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Exception(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
val user = RevoltJson.decodeFromString(User.serializer(), response)
|
||||
val user = PeptideJson.decodeFromString(User.serializer(), response)
|
||||
|
||||
user.id?.let {
|
||||
RevoltAPI.userCache[it] = user
|
||||
PeptideAPI.userCache[it] = user
|
||||
}
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
suspend fun getOrFetchUser(id: String): User {
|
||||
return RevoltAPI.userCache[id] ?: fetchUser(id)
|
||||
return PeptideAPI.userCache[id] ?: fetchUser(id)
|
||||
}
|
||||
|
||||
suspend fun addUserIfUnknown(id: String) {
|
||||
if (RevoltAPI.userCache[id] == null) {
|
||||
RevoltAPI.userCache[id] = fetchUser(id)
|
||||
if (PeptideAPI.userCache[id] == null) {
|
||||
PeptideAPI.userCache[id] = fetchUser(id)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun fetchUserProfile(id: String): Profile {
|
||||
val res = RevoltHttp.get("/users/$id/profile".api())
|
||||
val res = PeptideHttp.get("/users/$id/profile".api())
|
||||
|
||||
val response = res.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Exception(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
return RevoltJson.decodeFromString(Profile.serializer(), response)
|
||||
return PeptideJson.decodeFromString(Profile.serializer(), response)
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package chat.peptide.api.routes.voice
|
||||
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.api
|
||||
import io.ktor.client.request.post
|
||||
import io.ktor.client.request.setBody
|
||||
|
|
@ -19,17 +19,17 @@ data class JoinCallResponse(
|
|||
)
|
||||
|
||||
suspend fun joinCall(channelId: String, nodeName: String): JoinCallResponse {
|
||||
val response = RevoltHttp.post("/channels/$channelId/join_call".api()) {
|
||||
val response = PeptideHttp.post("/channels/$channelId/join_call".api()) {
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(mapOf("node" to nodeName))
|
||||
}.bodyAsText()
|
||||
|
||||
try {
|
||||
val error = RevoltJson.decodeFromString(RevoltError.serializer(), response)
|
||||
val error = PeptideJson.decodeFromString(PeptideError.serializer(), response)
|
||||
throw Exception(error.type)
|
||||
} catch (e: SerializationException) {
|
||||
// Not an error
|
||||
}
|
||||
|
||||
return RevoltJson.decodeFromString(JoinCallResponse.serializer(), response)
|
||||
return PeptideJson.decodeFromString(JoinCallResponse.serializer(), response)
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package chat.peptide.api.schemas
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
|
@ -10,6 +10,6 @@ data class Session(
|
|||
val name: String
|
||||
) {
|
||||
fun isCurrent(): Boolean {
|
||||
return id == RevoltAPI.sessionId
|
||||
return id == PeptideAPI.sessionId
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package chat.peptide.api.schemas
|
|||
|
||||
import android.net.Uri
|
||||
import androidx.core.net.toUri
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
|
@ -51,10 +51,10 @@ data class InviteJoined(
|
|||
|
||||
fun Uri.isInviteUri(): Boolean {
|
||||
val firstPathSegmentIsInvite = this.pathSegments.firstOrNull() == "invite"
|
||||
val isAppRevoltChat = this.host == RevoltAPI.getCurrentAppUrl().toUri().host
|
||||
val matchRvltGG = this.host == RevoltAPI.getCurrentInvitesUrl().toUri().host
|
||||
val isAppPeptideChat = this.host == PeptideAPI.getCurrentAppUrl().toUri().host
|
||||
val matchRvltGG = this.host == PeptideAPI.getCurrentInvitesUrl().toUri().host
|
||||
|
||||
val matchApp = isAppRevoltChat && firstPathSegmentIsInvite
|
||||
val matchApp = isAppPeptideChat && firstPathSegmentIsInvite
|
||||
|
||||
val hasEnoughSegments =
|
||||
if (matchApp) this.pathSegments.size == 2 else this.pathSegments.size == 1
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package chat.peptide.api.schemas
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ data class Message(
|
|||
val tail: Boolean? = null // this is used to determine if the message is the last in a message group
|
||||
) {
|
||||
fun getAuthor(): User? {
|
||||
return author?.let { RevoltAPI.userCache[it] }
|
||||
return author?.let { PeptideAPI.userCache[it] }
|
||||
}
|
||||
|
||||
fun mergeWithPartial(partial: Message): Message {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ data class AndroidSpecificSettingsSpecialEmbedSettings(
|
|||
data class AndroidSpecificSettings(
|
||||
/**
|
||||
* The theme to use for the app.
|
||||
* Can be one of `{ None, Revolt, Light, M3Dynamic, Amoled }`
|
||||
* Can be one of `{ None, Peptide, Light, M3Dynamic, Amoled }`
|
||||
*/
|
||||
var theme: String? = null,
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import androidx.compose.runtime.getValue
|
|||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import chat.peptide.BuildConfig
|
||||
import chat.peptide.RevoltApplication
|
||||
import chat.peptide.PeptideApplication
|
||||
import chat.peptide.persistence.KVStorage
|
||||
|
||||
class ExperimentInstance(default: Boolean) {
|
||||
|
|
@ -31,7 +31,7 @@ object Experiments {
|
|||
val enableServerIdentityOptions = ExperimentInstance(false)
|
||||
|
||||
suspend fun hydrateWithKv() {
|
||||
val kvStorage = KVStorage(RevoltApplication.instance)
|
||||
val kvStorage = KVStorage(PeptideApplication.instance)
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
LoadedSettings.experimentsEnabled = true
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package chat.peptide.api.settings
|
|||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.SpecialUsers
|
||||
|
||||
annotation class FeatureFlag(val name: String)
|
||||
|
|
@ -60,7 +60,7 @@ object FeatureFlags {
|
|||
@FeatureFlag("LabsAccessControl")
|
||||
var labsAccessControl by mutableStateOf<LabsAccessControlVariates>(
|
||||
LabsAccessControlVariates.Restricted {
|
||||
RevoltAPI.selfId == SpecialUsers.JENNIFER
|
||||
PeptideAPI.selfId == SpecialUsers.JENNIFER
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ object FeatureFlags {
|
|||
@FeatureFlag("UserCards")
|
||||
var userCards by mutableStateOf<UserCardsVariates>(
|
||||
UserCardsVariates.Restricted {
|
||||
RevoltAPI.selfId?.endsWith("Z") == true
|
||||
PeptideAPI.selfId?.endsWith("Z") == true
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,16 @@ object LoadedSettings {
|
|||
var poorlyFormedSettingsKeys by mutableStateOf(emptySet<String>())
|
||||
|
||||
fun hydrateWithSettings(settings: SyncedSettings) {
|
||||
this.theme = settings.android.theme?.let { Theme.valueOf(it) } ?: getDefaultTheme()
|
||||
this.messageReplyStyle =
|
||||
settings.android.messageReplyStyle?.let { MessageReplyStyle.valueOf(it) }
|
||||
?: MessageReplyStyle.SwipeFromEnd
|
||||
this.avatarRadius = settings.android.avatarRadius ?: 50
|
||||
this.specialEmbedSettings = settings.android.specialEmbedSettings ?: SpecialEmbedSettings()
|
||||
try {
|
||||
this.theme = settings.android.theme?.let { Theme.valueOf(it) } ?: getDefaultTheme()
|
||||
this.messageReplyStyle =
|
||||
settings.android.messageReplyStyle?.let { MessageReplyStyle.valueOf(it) }
|
||||
?: MessageReplyStyle.SwipeFromEnd
|
||||
this.avatarRadius = settings.android.avatarRadius ?: 50
|
||||
this.specialEmbedSettings = settings.android.specialEmbedSettings ?: SpecialEmbedSettings()
|
||||
} catch (_: Exception) {
|
||||
reset()
|
||||
}
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package chat.peptide.api.settings
|
||||
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.routes.sync.getKeys
|
||||
import chat.peptide.api.routes.sync.setKey
|
||||
import chat.peptide.api.schemas.AndroidSpecificSettings
|
||||
|
|
@ -40,14 +40,14 @@ object SyncedSettings {
|
|||
val notifications: NotificationSettings
|
||||
get() = _notifications.value
|
||||
|
||||
suspend fun fetch(revoltToken: String = RevoltAPI.sessionToken) {
|
||||
suspend fun fetch(peptideToken: String = PeptideAPI.sessionToken) {
|
||||
try {
|
||||
val settings =
|
||||
getKeys("ordering", "android", "notifications", revoltToken = revoltToken)
|
||||
getKeys("ordering", "android", "notifications", peptideToken = peptideToken)
|
||||
|
||||
settings["ordering"]?.let {
|
||||
try {
|
||||
_ordering.value = RevoltJson.decodeFromString(
|
||||
_ordering.value = PeptideJson.decodeFromString(
|
||||
OrderingSettings.serializer(),
|
||||
it.value
|
||||
)
|
||||
|
|
@ -59,7 +59,7 @@ object SyncedSettings {
|
|||
|
||||
settings["android"]?.let {
|
||||
try {
|
||||
_android.value = RevoltJson.decodeFromString(
|
||||
_android.value = PeptideJson.decodeFromString(
|
||||
AndroidSpecificSettings.serializer(),
|
||||
it.value
|
||||
)
|
||||
|
|
@ -82,7 +82,7 @@ object SyncedSettings {
|
|||
private fun parseNotificationSettings(value: String): NotificationSettings {
|
||||
return try {
|
||||
var intermediate =
|
||||
RevoltJson.decodeFromString(_NotificationSettingsToParse.serializer(), value)
|
||||
PeptideJson.decodeFromString(_NotificationSettingsToParse.serializer(), value)
|
||||
|
||||
// Throw out any value of intermediate.server and .channel that isn't a string
|
||||
intermediate = intermediate.copy(
|
||||
|
|
@ -108,23 +108,23 @@ object SyncedSettings {
|
|||
|
||||
suspend fun updateOrdering(value: OrderingSettings) {
|
||||
_ordering.value = value
|
||||
setKey("ordering", RevoltJson.encodeToString(OrderingSettings.serializer(), value))
|
||||
setKey("ordering", PeptideJson.encodeToString(OrderingSettings.serializer(), value))
|
||||
}
|
||||
|
||||
suspend fun updateAndroid(value: AndroidSpecificSettings) {
|
||||
_android.value = value
|
||||
setKey("android", RevoltJson.encodeToString(AndroidSpecificSettings.serializer(), value))
|
||||
setKey("android", PeptideJson.encodeToString(AndroidSpecificSettings.serializer(), value))
|
||||
}
|
||||
|
||||
suspend fun updateNotifications(value: NotificationSettings) {
|
||||
_notifications.value = value
|
||||
setKey("notifications", RevoltJson.encodeToString(NotificationSettings.serializer(), value))
|
||||
setKey("notifications", PeptideJson.encodeToString(NotificationSettings.serializer(), value))
|
||||
}
|
||||
|
||||
suspend fun resetOrdering() {
|
||||
val default = OrderingSettings()
|
||||
_ordering.value = default
|
||||
setKey("ordering", RevoltJson.encodeToString(OrderingSettings.serializer(), default))
|
||||
setKey("ordering", PeptideJson.encodeToString(OrderingSettings.serializer(), default))
|
||||
}
|
||||
|
||||
suspend fun resetAndroid() {
|
||||
|
|
@ -134,7 +134,7 @@ object SyncedSettings {
|
|||
messageReplyStyle = "None"
|
||||
)
|
||||
_android.value = default
|
||||
setKey("android", RevoltJson.encodeToString(AndroidSpecificSettings.serializer(), default))
|
||||
setKey("android", PeptideJson.encodeToString(AndroidSpecificSettings.serializer(), default))
|
||||
}
|
||||
|
||||
suspend fun resetNotifications() {
|
||||
|
|
@ -142,7 +142,7 @@ object SyncedSettings {
|
|||
_notifications.value = default
|
||||
setKey(
|
||||
"notifications",
|
||||
RevoltJson.encodeToString(NotificationSettings.serializer(), default)
|
||||
PeptideJson.encodeToString(NotificationSettings.serializer(), default)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package chat.peptide.api.unreads
|
|||
import android.util.Log
|
||||
import androidx.compose.runtime.mutableStateMapOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.ULID
|
||||
import chat.peptide.api.routes.channel.ackChannel
|
||||
import chat.peptide.api.routes.server.ackServer
|
||||
|
|
@ -50,8 +50,8 @@ class Unreads {
|
|||
fun serverHasUnread(serverId: String): Boolean {
|
||||
if (!hasLoaded.value) return false
|
||||
|
||||
return RevoltAPI.serverCache[serverId]?.channels?.any {
|
||||
val channel = RevoltAPI.channelCache[it] ?: return@any false // Channel not found
|
||||
return PeptideAPI.serverCache[serverId]?.channels?.any {
|
||||
val channel = PeptideAPI.channelCache[it] ?: return@any false // Channel not found
|
||||
if (channel.channelType == ChannelType.VoiceChannel) return@any false // Channel is voice
|
||||
if (NotificationSettingsProvider.isChannelMuted(
|
||||
it,
|
||||
|
|
@ -81,7 +81,7 @@ class Unreads {
|
|||
suspend fun markServerAsRead(serverId: String, sync: Boolean = true) {
|
||||
if (!hasLoaded.value) return
|
||||
|
||||
val server = RevoltAPI.serverCache[serverId] ?: return
|
||||
val server = PeptideAPI.serverCache[serverId] ?: return
|
||||
server.channels?.forEach { channel ->
|
||||
channels[channel] = channels[channel]?.copy(last_id = ULID.makeNext()) ?: ChannelUnread(
|
||||
channel,
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import androidx.core.app.RemoteInput
|
|||
import androidx.core.graphics.drawable.IconCompat
|
||||
import chat.peptide.R
|
||||
import chat.peptide.activities.MainActivity
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.internals.ULID
|
||||
import chat.peptide.api.routes.push.subscribePush
|
||||
import chat.peptide.api.schemas.Message
|
||||
|
|
@ -51,13 +51,13 @@ class HandlerService : FirebaseMessagingService() {
|
|||
|
||||
Log.d("HandlerService", payloadString)
|
||||
|
||||
val payload = RevoltJson.parseToJsonElement(payloadString).jsonObject
|
||||
val payload = PeptideJson.parseToJsonElement(payloadString).jsonObject
|
||||
val keys = payload.keys.toList().toString()
|
||||
Log.d("HandlerService", "following keys: $keys")
|
||||
|
||||
var authorIcon = payload["icon"]?.jsonPrimitive?.contentOrNull
|
||||
val message = payload["message"]?.jsonObject?.let {
|
||||
RevoltJson.decodeFromJsonElement(
|
||||
PeptideJson.decodeFromJsonElement(
|
||||
Message.serializer(),
|
||||
it
|
||||
)
|
||||
|
|
@ -67,7 +67,7 @@ class HandlerService : FirebaseMessagingService() {
|
|||
}
|
||||
|
||||
val user = payload["message"]?.jsonObject?.get("user")?.jsonObject?.let {
|
||||
RevoltJson.decodeFromJsonElement(
|
||||
PeptideJson.decodeFromJsonElement(
|
||||
User.serializer(),
|
||||
it
|
||||
)
|
||||
|
|
@ -78,7 +78,7 @@ class HandlerService : FirebaseMessagingService() {
|
|||
|
||||
if (authorIcon == null) {
|
||||
authorIcon =
|
||||
"${RevoltAPI.getCurrentBaseUrl()}/users/${message.author?.ifBlank { "0".repeat(26) }}/default_avatar"
|
||||
"${PeptideAPI.getCurrentBaseUrl()}/users/${message.author?.ifBlank { "0".repeat(26) }}/default_avatar"
|
||||
}
|
||||
|
||||
val db = Database(SqlStorage.driver)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.solidColor
|
||||
import chat.peptide.api.routes.channel.fetchSingleMessage
|
||||
import chat.peptide.api.schemas.User
|
||||
|
|
@ -47,8 +47,8 @@ fun InReplyTo(
|
|||
withMention: Boolean = false,
|
||||
onMessageClick: (String) -> Unit = { _ -> }
|
||||
) {
|
||||
val message = RevoltAPI.messageCache[messageId]
|
||||
val author = RevoltAPI.userCache[message?.author ?: ""]
|
||||
val message = PeptideAPI.messageCache[messageId]
|
||||
val author = PeptideAPI.userCache[message?.author ?: ""]
|
||||
|
||||
val username = message?.let { authorName(it) }
|
||||
?: author?.let { User.resolveDefaultName(it) }
|
||||
|
|
@ -58,12 +58,12 @@ fun InReplyTo(
|
|||
val usernameColor =
|
||||
message?.let { authorColour(it) } ?: Brush.solidColor(contentColor)
|
||||
|
||||
val serverId = remember(channelId) { RevoltAPI.channelCache[channelId]?.server }
|
||||
val serverId = remember(channelId) { PeptideAPI.channelCache[channelId]?.server }
|
||||
|
||||
LaunchedEffect(messageId) {
|
||||
if (messageId !in RevoltAPI.messageCache) {
|
||||
if (messageId !in PeptideAPI.messageCache) {
|
||||
try {
|
||||
RevoltAPI.messageCache[messageId] = fetchSingleMessage(channelId, messageId)
|
||||
PeptideAPI.messageCache[messageId] = fetchSingleMessage(channelId, messageId)
|
||||
} catch (e: CancellationException) {
|
||||
// It's fine
|
||||
} catch (e: Exception) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.BrushCompat
|
||||
import chat.peptide.api.internals.Roles
|
||||
import chat.peptide.api.internals.solidColor
|
||||
|
|
@ -74,7 +74,7 @@ fun MemberListItem(
|
|||
?: user?.id
|
||||
?: userId,
|
||||
avatar = user?.avatar,
|
||||
rawUrl = member?.avatar?.let { "${RevoltAPI.getCurrentFilesUrl()}/avatars/${it.id}" },
|
||||
rawUrl = member?.avatar?.let { "${PeptideAPI.getCurrentFilesUrl()}/avatars/${it.id}" },
|
||||
userId = userId,
|
||||
presence = presenceFromStatus(
|
||||
user?.status?.presence,
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ import androidx.compose.ui.unit.sp
|
|||
import chat.peptide.R
|
||||
import chat.peptide.activities.media.ImageViewActivity
|
||||
import chat.peptide.activities.media.VideoViewActivity
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.BrushCompat
|
||||
import chat.peptide.api.internals.MessageFlag
|
||||
import chat.peptide.api.internals.Roles
|
||||
|
|
@ -103,7 +103,7 @@ fun authorColour(message: MessageSchema): Brush {
|
|||
} else {
|
||||
val defaultColour = Brush.solidColor(LocalContentColor.current)
|
||||
|
||||
val serverId = RevoltAPI.channelCache[message.channel]?.server ?: return defaultColour
|
||||
val serverId = PeptideAPI.channelCache[message.channel]?.server ?: return defaultColour
|
||||
|
||||
val highestRole = message.author?.let {
|
||||
Roles.resolveHighestRole(serverId, it, withColour = true)
|
||||
|
|
@ -121,14 +121,14 @@ fun authorName(message: MessageSchema): String {
|
|||
}
|
||||
|
||||
val serverId =
|
||||
RevoltAPI.channelCache[message.channel]?.server
|
||||
?: return RevoltAPI.userCache[message.author]?.let { User.resolveDefaultName(it) }
|
||||
PeptideAPI.channelCache[message.channel]?.server
|
||||
?: return PeptideAPI.userCache[message.author]?.let { User.resolveDefaultName(it) }
|
||||
?: stringResource(R.string.unknown)
|
||||
|
||||
val member = message.author?.let { RevoltAPI.members.getMember(serverId, it) }
|
||||
val member = message.author?.let { PeptideAPI.members.getMember(serverId, it) }
|
||||
?: return stringResource(R.string.unknown)
|
||||
return member.nickname
|
||||
?: RevoltAPI.userCache[message.author]?.let { User.resolveDefaultName(it) }
|
||||
?: PeptideAPI.userCache[message.author]?.let { User.resolveDefaultName(it) }
|
||||
?: stringResource(R.string.unknown)
|
||||
}
|
||||
|
||||
|
|
@ -139,11 +139,11 @@ fun authorAvatarUrl(message: MessageSchema): String? {
|
|||
}
|
||||
|
||||
val serverId =
|
||||
RevoltAPI.channelCache[message.channel]?.server ?: return null
|
||||
val member = message.author?.let { RevoltAPI.members.getMember(serverId, it) }
|
||||
PeptideAPI.channelCache[message.channel]?.server ?: return null
|
||||
val member = message.author?.let { PeptideAPI.members.getMember(serverId, it) }
|
||||
?: return null
|
||||
|
||||
return member.avatar?.let { "${RevoltAPI.getCurrentFilesUrl()}/avatars/${it.id}" }
|
||||
return member.avatar?.let { "${PeptideAPI.getCurrentFilesUrl()}/avatars/${it.id}" }
|
||||
}
|
||||
|
||||
fun viewUrlInBrowser(ctx: android.content.Context, url: String) {
|
||||
|
|
@ -184,7 +184,7 @@ fun viewUrlInBrowser(ctx: android.content.Context, url: String) {
|
|||
|
||||
fun viewAttachmentInBrowser(ctx: android.content.Context, attachment: AutumnResource) {
|
||||
val url =
|
||||
"${RevoltAPI.getCurrentFilesUrl()}/attachments/${attachment.id}/${attachment.filename}"
|
||||
"${PeptideAPI.getCurrentFilesUrl()}/attachments/${attachment.id}/${attachment.filename}"
|
||||
viewUrlInBrowser(ctx, url)
|
||||
}
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ fun Message(
|
|||
fromWebhook: Boolean = false,
|
||||
webhookName: String? = null,
|
||||
) {
|
||||
val author = RevoltAPI.userCache[message.author] ?: return CircularProgressIndicator()
|
||||
val author = PeptideAPI.userCache[message.author] ?: return CircularProgressIndicator()
|
||||
val context = LocalContext.current
|
||||
|
||||
val scope = rememberCoroutineScope()
|
||||
|
|
@ -261,8 +261,8 @@ fun Message(
|
|||
var mentionsSelfRole by remember(message) { mutableStateOf(false) }
|
||||
LaunchedEffect(Unit) {
|
||||
val serverId =
|
||||
RevoltAPI.channelCache[message.channel]?.server ?: return@LaunchedEffect
|
||||
var selfMember = RevoltAPI.selfId?.let { RevoltAPI.members.getMember(serverId, it) }
|
||||
PeptideAPI.channelCache[message.channel]?.server ?: return@LaunchedEffect
|
||||
var selfMember = PeptideAPI.selfId?.let { PeptideAPI.members.getMember(serverId, it) }
|
||||
?: return@LaunchedEffect
|
||||
var messageRoleMentions = MessageProcessor.findMentionedRoleIDs(message.content)
|
||||
|
||||
|
|
@ -312,7 +312,7 @@ fun Message(
|
|||
} else {
|
||||
Column(
|
||||
modifier = Modifier.then(
|
||||
if ((message.mentions?.contains(RevoltAPI.selfId) == true)
|
||||
if ((message.mentions?.contains(PeptideAPI.selfId) == true)
|
||||
|| mentionsSelfRole
|
||||
|| message.flags has MessageFlag.MentionsOnline
|
||||
|| message.flags has MessageFlag.MentionsEveryone
|
||||
|
|
@ -326,7 +326,7 @@ fun Message(
|
|||
)
|
||||
) {
|
||||
message.replies?.forEach { reply ->
|
||||
val replyMessage = RevoltAPI.messageCache[reply]
|
||||
val replyMessage = PeptideAPI.messageCache[reply]
|
||||
|
||||
message.channel?.let { chId ->
|
||||
InReplyTo(
|
||||
|
|
@ -462,7 +462,7 @@ fun Message(
|
|||
if (Experiments.useKotlinBasedMarkdownRenderer.isEnabled) {
|
||||
CompositionLocalProvider(
|
||||
LocalJBMarkdownTreeState provides LocalJBMarkdownTreeState.current.copy(
|
||||
currentServer = RevoltAPI.channelCache[message.channel]?.server,
|
||||
currentServer = PeptideAPI.channelCache[message.channel]?.server,
|
||||
fontSizeMultiplier = Gigamoji.useGigamojiForMessage(
|
||||
message.content
|
||||
)
|
||||
|
|
@ -477,7 +477,7 @@ fun Message(
|
|||
} else {
|
||||
CompositionLocalProvider(
|
||||
LocalMarkdownTreeConfig provides LocalMarkdownTreeConfig.current.copy(
|
||||
currentServer = RevoltAPI.channelCache[message.channel]?.server,
|
||||
currentServer = PeptideAPI.channelCache[message.channel]?.server,
|
||||
fontSizeMultiplier = Gigamoji.useGigamojiForMessage(
|
||||
message.content
|
||||
)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.schemas.AutumnResource
|
||||
import chat.peptide.composables.generic.RemoteImage
|
||||
import chat.peptide.composables.media.AudioPlayer
|
||||
|
|
@ -83,7 +83,7 @@ fun FileAttachment(attachment: AutumnResource) {
|
|||
@SuppressLint("UnusedBoxWithConstraintsScope")
|
||||
@Composable
|
||||
fun ImageAttachment(attachment: AutumnResource) {
|
||||
val url = "${RevoltAPI.getCurrentFilesUrl()}/attachments/${attachment.id}/${attachment.filename}"
|
||||
val url = "${PeptideAPI.getCurrentFilesUrl()}/attachments/${attachment.id}/${attachment.filename}"
|
||||
var spoilerShown by remember { mutableStateOf(false) }
|
||||
val hazeState =
|
||||
if (attachment.filename?.startsWith("SPOILER_") == true) rememberHazeState() else null
|
||||
|
|
@ -149,7 +149,7 @@ fun VideoPlayButton() {
|
|||
@SuppressLint("UnusedBoxWithConstraintsScope")
|
||||
@Composable
|
||||
fun VideoAttachment(attachment: AutumnResource) {
|
||||
val url = "${RevoltAPI.getCurrentFilesUrl()}/attachments/${attachment.id}/${attachment.filename}"
|
||||
val url = "${PeptideAPI.getCurrentFilesUrl()}/attachments/${attachment.id}/${attachment.filename}"
|
||||
|
||||
BoxWithConstraints {
|
||||
Box(
|
||||
|
|
@ -179,7 +179,7 @@ fun VideoAttachment(attachment: AutumnResource) {
|
|||
|
||||
@Composable
|
||||
fun AudioAttachment(attachment: AutumnResource) {
|
||||
val url = "${RevoltAPI.getCurrentFilesUrl()}/attachments/${attachment.id}/${attachment.filename}"
|
||||
val url = "${PeptideAPI.getCurrentFilesUrl()}/attachments/${attachment.id}/${attachment.filename}"
|
||||
AudioPlayer(
|
||||
url = url,
|
||||
filename = attachment.filename ?: "Audio",
|
||||
|
|
|
|||
|
|
@ -80,9 +80,9 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.IntSize
|
||||
import androidx.compose.ui.unit.dp
|
||||
import chat.peptide.R
|
||||
import chat.peptide.activities.RevoltTweenFloat
|
||||
import chat.peptide.activities.RevoltTweenInt
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.activities.PeptideTweenFloat
|
||||
import chat.peptide.activities.PeptideTweenInt
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.BrushCompat
|
||||
import chat.peptide.api.schemas.ChannelType
|
||||
import chat.peptide.api.schemas.Member
|
||||
|
|
@ -318,7 +318,7 @@ fun MessageField(
|
|||
userId = item.user.id ?: "",
|
||||
avatar = item.user.avatar,
|
||||
rawUrl = item.member?.avatar?.id?.let {
|
||||
"${RevoltAPI.getCurrentFilesUrl()}/avatars/$it"
|
||||
"${PeptideAPI.getCurrentFilesUrl()}/avatars/$it"
|
||||
},
|
||||
size = SuggestionChipDefaults.IconSize,
|
||||
)
|
||||
|
|
@ -444,7 +444,7 @@ fun MessageField(
|
|||
)
|
||||
} else {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/emojis/${item.custom?.id}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/emojis/${item.custom?.id}",
|
||||
description = null,
|
||||
contentScale = ContentScale.Fit,
|
||||
modifier = Modifier
|
||||
|
|
@ -606,18 +606,18 @@ fun MessageField(
|
|||
full.height
|
||||
)
|
||||
}) + slideInHorizontally(
|
||||
animationSpec = RevoltTweenInt,
|
||||
animationSpec = PeptideTweenInt,
|
||||
initialOffsetX = { -it }
|
||||
) + fadeIn(animationSpec = RevoltTweenFloat),
|
||||
) + fadeIn(animationSpec = PeptideTweenFloat),
|
||||
exit = shrinkOut(targetSize = { full ->
|
||||
IntSize(
|
||||
0,
|
||||
full.height
|
||||
)
|
||||
}) + slideOutHorizontally(
|
||||
animationSpec = RevoltTweenInt,
|
||||
animationSpec = PeptideTweenInt,
|
||||
targetOffsetX = { it }
|
||||
) + fadeOut(animationSpec = RevoltTweenFloat)
|
||||
) + fadeOut(animationSpec = PeptideTweenFloat)
|
||||
) {
|
||||
Icon(
|
||||
painter = when {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import androidx.compose.ui.text.font.FontWeight
|
|||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.isUlid
|
||||
import chat.peptide.composables.generic.RemoteImage
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ fun Reaction(
|
|||
onClick: (Boolean) -> Unit,
|
||||
onLongClick: () -> Unit
|
||||
) {
|
||||
val hasOwn = members.contains(RevoltAPI.selfId)
|
||||
val hasOwn = members.contains(PeptideAPI.selfId)
|
||||
|
||||
val background by animateColorAsState(
|
||||
targetValue = if (hasOwn) {
|
||||
|
|
@ -73,7 +73,7 @@ fun Reaction(
|
|||
CompositionLocalProvider(LocalContentColor provides foreground) {
|
||||
if (emoji.isUlid()) {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/emojis/${emoji}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/emojis/${emoji}",
|
||||
description = null,
|
||||
modifier = Modifier.size(16.dp)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ import androidx.compose.ui.unit.Dp
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import chat.peptide.R
|
||||
import chat.peptide.activities.RevoltTweenFloat
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.activities.PeptideTweenFloat
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.callbacks.Action
|
||||
import chat.peptide.callbacks.ActionChannel
|
||||
import chat.peptide.composables.generic.IconPlaceholder
|
||||
|
|
@ -132,12 +132,12 @@ fun EmojiPicker(
|
|||
var showSkinToneMenu by remember { mutableStateOf(false) }
|
||||
val skinToneMenuAreaWeight by animateFloatAsState(
|
||||
if (showSkinToneMenu) 1f else .15f,
|
||||
animationSpec = RevoltTweenFloat,
|
||||
animationSpec = PeptideTweenFloat,
|
||||
label = "skinToneMenuAreaWeight"
|
||||
)
|
||||
val skinToneMenuCloseHintIconOpacity by animateFloatAsState(
|
||||
if (showSkinToneMenu) 1f else 0f,
|
||||
animationSpec = RevoltTweenFloat,
|
||||
animationSpec = PeptideTweenFloat,
|
||||
label = "skinToneMenuCloseHintIconOpacity"
|
||||
)
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ fun EmojiPicker(
|
|||
var searchQuery by remember { mutableStateOf("") }
|
||||
val searchFieldOpacity by animateFloatAsState(
|
||||
if (showSkinToneMenu) 0f else 1f,
|
||||
animationSpec = RevoltTweenFloat,
|
||||
animationSpec = PeptideTweenFloat,
|
||||
label = "searchFieldOpacity"
|
||||
)
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ fun EmojiPicker(
|
|||
}
|
||||
val clearQueryButtonOpacity = animateFloatAsState(
|
||||
if (searchQuery.isNotEmpty()) 1f else 0f,
|
||||
animationSpec = RevoltTweenFloat,
|
||||
animationSpec = PeptideTweenFloat,
|
||||
label = "clearQueryButtonOpacity"
|
||||
)
|
||||
|
||||
|
|
@ -401,7 +401,7 @@ fun EmojiPicker(
|
|||
)
|
||||
} else {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/icons/${server.icon.id}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/icons/${server.icon.id}",
|
||||
allowAnimation = false,
|
||||
description = server.name,
|
||||
modifier = Modifier
|
||||
|
|
@ -619,7 +619,7 @@ fun ColumnScope.PickerItem(
|
|||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/emojis/${item.emote.id}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/emojis/${item.emote.id}",
|
||||
description = item.emote.name,
|
||||
contentScale = ContentScale.Fit,
|
||||
modifier = Modifier
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.schemas.AutumnResource
|
||||
import chat.peptide.api.settings.LoadedSettings
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ fun UserAvatar(
|
|||
) {
|
||||
if (avatar != null) {
|
||||
RemoteImage(
|
||||
url = rawUrl ?: "${RevoltAPI.getCurrentFilesUrl()}/avatars/${avatar.id}",
|
||||
url = rawUrl ?: "${PeptideAPI.getCurrentFilesUrl()}/avatars/${avatar.id}",
|
||||
contentScale = ContentScale.Crop,
|
||||
description = stringResource(id = R.string.avatar_alt, username),
|
||||
allowAnimation = allowAnimation,
|
||||
|
|
@ -124,7 +124,7 @@ fun UserAvatar(
|
|||
)
|
||||
} else {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentBaseUrl()}/users/${userId.ifBlank { "0".repeat(26) }}/default_avatar",
|
||||
url = "${PeptideAPI.getCurrentBaseUrl()}/users/${userId.ifBlank { "0".repeat(26) }}/default_avatar",
|
||||
description = stringResource(id = R.string.avatar_alt, username),
|
||||
allowAnimation = allowAnimation,
|
||||
modifier = Modifier
|
||||
|
|
@ -168,7 +168,7 @@ fun GroupIcon(
|
|||
) {
|
||||
if (icon?.id != null) {
|
||||
RemoteImage(
|
||||
url = rawUrl ?: "${RevoltAPI.getCurrentFilesUrl()}/icons/${icon.id}",
|
||||
url = rawUrl ?: "${PeptideAPI.getCurrentFilesUrl()}/icons/${icon.id}",
|
||||
allowAnimation = false,
|
||||
contentScale = ContentScale.Crop,
|
||||
description = stringResource(id = R.string.avatar_alt, name),
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ fun AnyLink(text: String, action: () -> Unit, modifier: Modifier = Modifier) {
|
|||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun WeblinkPreview() {
|
||||
Weblink(text = "https://revolt.chat", url = "https://revolt.chat")
|
||||
Weblink(text = "https://peptide.chat", url = "https://peptide.chat")
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import androidx.compose.ui.text.font.FontWeight
|
|||
import androidx.core.net.toUri
|
||||
import chat.peptide.R
|
||||
import chat.peptide.activities.InviteActivity
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.routes.custom.fetchEmoji
|
||||
import chat.peptide.api.schemas.isInviteUri
|
||||
import chat.peptide.callbacks.Action
|
||||
|
|
@ -102,10 +102,10 @@ fun annotateText(node: AstNode): AnnotatedString {
|
|||
)
|
||||
)
|
||||
val member = LocalMarkdownTreeConfig.current.currentServer?.let { serverId ->
|
||||
RevoltAPI.members.getMember(serverId, mention.groupValues[1])
|
||||
PeptideAPI.members.getMember(serverId, mention.groupValues[1])
|
||||
}
|
||||
val content = member?.nickname?.let { nick -> "@$nick" }
|
||||
?: RevoltAPI.userCache[mention.groupValues[1]]?.username?.let { username -> "@$username" }
|
||||
?: PeptideAPI.userCache[mention.groupValues[1]]?.username?.let { username -> "@$username" }
|
||||
?: "<@${mention.groupValues[1]}>"
|
||||
append(content)
|
||||
pop()
|
||||
|
|
@ -131,7 +131,7 @@ fun annotateText(node: AstNode): AnnotatedString {
|
|||
)
|
||||
)
|
||||
val content =
|
||||
RevoltAPI.channelCache[channel.groupValues[1]]?.name?.let { chId -> "#$chId" }
|
||||
PeptideAPI.channelCache[channel.groupValues[1]]?.name?.let { chId -> "#$chId" }
|
||||
?: "<#${channel.groupValues[1]}>"
|
||||
append(content)
|
||||
pop()
|
||||
|
|
@ -200,7 +200,7 @@ fun annotateText(node: AstNode): AnnotatedString {
|
|||
pushStyle(
|
||||
LocalTextStyle.current.toSpanStyle()
|
||||
.copy(
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
color = MaterialTheme.colorScheme.secondary
|
||||
)
|
||||
)
|
||||
append(url.value)
|
||||
|
|
@ -244,7 +244,7 @@ fun annotateText(node: AstNode): AnnotatedString {
|
|||
pushStyle(
|
||||
LocalTextStyle.current.toSpanStyle()
|
||||
.copy(
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
color = MaterialTheme.colorScheme.secondary
|
||||
)
|
||||
)
|
||||
node.children?.forEach { append(annotateText(it)) }
|
||||
|
|
@ -326,22 +326,11 @@ fun MarkdownText(textNode: AstNode, modifier: Modifier = Modifier) {
|
|||
// no-op
|
||||
}
|
||||
|
||||
// Check if this is an internal link that should be handled by the app
|
||||
Log.d("MarkdownText", "Checking if URL is internal link")
|
||||
if (InternalLinkHandler.isInternalLink(url)) {
|
||||
Log.d("MarkdownText", "URL is internal link, attempting to handle internally")
|
||||
// Try to handle the link internally
|
||||
val handled = InternalLinkHandler.handleInternalLink(context, url, true)
|
||||
Log.d("MarkdownText", "Internal link handled: $handled")
|
||||
if (handled) {
|
||||
// Link was handled internally
|
||||
Log.d("MarkdownText", "Link handled internally, returning")
|
||||
return@handler true
|
||||
} else {
|
||||
Log.d("MarkdownText", "Failed to handle link internally, falling back to browser")
|
||||
}
|
||||
} else {
|
||||
Log.d("MarkdownText", "URL is not internal link, opening in browser")
|
||||
}
|
||||
|
||||
// If not an internal link or couldn't be handled internally, open in browser
|
||||
|
|
@ -443,11 +432,11 @@ fun MarkdownText(textNode: AstNode, modifier: Modifier = Modifier) {
|
|||
placeholderVerticalAlign = PlaceholderVerticalAlign.Center
|
||||
),
|
||||
) { id ->
|
||||
val emote = RevoltAPI.emojiCache[id]
|
||||
val emote = PeptideAPI.emojiCache[id]
|
||||
if (emote == null) {
|
||||
scope.launch {
|
||||
try {
|
||||
RevoltAPI.emojiCache[id] = fetchEmoji(id)
|
||||
PeptideAPI.emojiCache[id] = fetchEmoji(id)
|
||||
} catch (e: Exception) {
|
||||
// no-op
|
||||
}
|
||||
|
|
@ -456,7 +445,7 @@ fun MarkdownText(textNode: AstNode, modifier: Modifier = Modifier) {
|
|||
} else {
|
||||
with(LocalDensity.current) {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/emojis/${id}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/emojis/${id}",
|
||||
description = emote.name,
|
||||
contentScale = ContentScale.Fit,
|
||||
modifier = Modifier
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import androidx.media3.common.MediaItem
|
|||
import androidx.media3.common.Player
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.statement.readBytes
|
||||
import kotlinx.coroutines.delay
|
||||
|
|
@ -118,13 +118,13 @@ fun AudioPlayer(url: String, filename: String, contentType: String) {
|
|||
ContentValues().apply {
|
||||
put(MediaStore.Audio.Media.DISPLAY_NAME, filename)
|
||||
put(MediaStore.Audio.Media.MIME_TYPE, contentType)
|
||||
put(MediaStore.Audio.Media.RELATIVE_PATH, "Music/Revolt")
|
||||
put(MediaStore.Audio.Media.RELATIVE_PATH, "Music/Peptide")
|
||||
put(MediaStore.Audio.Media.IS_PENDING, 1)
|
||||
}
|
||||
)
|
||||
}?.let { uri ->
|
||||
context.contentResolver.openOutputStream(uri).use { stream ->
|
||||
val audio = RevoltHttp.get(url).readBytes()
|
||||
val audio = PeptideHttp.get(url).readBytes()
|
||||
stream?.write(audio)
|
||||
|
||||
context.applicationContext.let {
|
||||
|
|
|
|||
|
|
@ -142,32 +142,32 @@ fun UserCard(
|
|||
LocalTextStyle provides LocalTextStyle.current.copy(
|
||||
fontFamily = FontFamily(
|
||||
Font(
|
||||
R.font.revolt_usercard,
|
||||
R.font.peptide_usercard,
|
||||
variationSettings = FontVariation.Settings(FontVariation.weight(200)),
|
||||
weight = FontWeight.ExtraLight
|
||||
),
|
||||
Font(
|
||||
R.font.revolt_usercard,
|
||||
R.font.peptide_usercard,
|
||||
variationSettings = FontVariation.Settings(FontVariation.weight(300)),
|
||||
weight = FontWeight.Light
|
||||
),
|
||||
Font(
|
||||
R.font.revolt_usercard,
|
||||
R.font.peptide_usercard,
|
||||
variationSettings = FontVariation.Settings(FontVariation.weight(400)),
|
||||
weight = FontWeight.Normal
|
||||
),
|
||||
Font(
|
||||
R.font.revolt_usercard,
|
||||
R.font.peptide_usercard,
|
||||
variationSettings = FontVariation.Settings(FontVariation.weight(500)),
|
||||
weight = FontWeight.Medium
|
||||
),
|
||||
Font(
|
||||
R.font.revolt_usercard,
|
||||
R.font.peptide_usercard,
|
||||
variationSettings = FontVariation.Settings(FontVariation.weight(700)),
|
||||
weight = FontWeight.Bold
|
||||
),
|
||||
Font(
|
||||
R.font.revolt_usercard,
|
||||
R.font.peptide_usercard,
|
||||
variationSettings = FontVariation.Settings(FontVariation.weight(900)),
|
||||
weight = FontWeight.Black
|
||||
)
|
||||
|
|
@ -342,7 +342,7 @@ fun UserCard(
|
|||
}
|
||||
|
||||
Text(
|
||||
"revolt.chat",
|
||||
"peptide.chat",
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import androidx.compose.ui.layout.ContentScale
|
|||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.schemas.AutumnResource
|
||||
import chat.peptide.api.schemas.ChannelType
|
||||
import chat.peptide.api.schemas.User
|
||||
|
|
@ -66,7 +66,7 @@ fun ChannelSheetHeader(
|
|||
) {
|
||||
if (channelIcon != null) {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/icons/${channelIcon.id ?: ""}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/icons/${channelIcon.id ?: ""}",
|
||||
description = null, // decorative
|
||||
contentScale = ContentScale.Crop,
|
||||
height = 48,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.ULID
|
||||
import chat.peptide.api.routes.channel.SendMessageReply
|
||||
import chat.peptide.api.schemas.Message
|
||||
|
|
@ -48,8 +48,8 @@ fun replyContentText(message: Message): String {
|
|||
|
||||
@Composable
|
||||
fun ManageableReply(reply: SendMessageReply, onToggleMention: () -> Unit, onRemove: () -> Unit) {
|
||||
val replyMessage = RevoltAPI.messageCache[reply.id] ?: return onRemove()
|
||||
val replyAuthor = RevoltAPI.userCache[replyMessage.author] ?: return onRemove()
|
||||
val replyMessage = PeptideAPI.messageCache[reply.id] ?: return onRemove()
|
||||
val replyAuthor = PeptideAPI.userCache[replyMessage.author] ?: return onRemove()
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ import androidx.compose.ui.unit.Dp
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import chat.peptide.R
|
||||
import chat.peptide.activities.RevoltTweenFloat
|
||||
import chat.peptide.activities.RevoltTweenInt
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.activities.PeptideTweenFloat
|
||||
import chat.peptide.activities.PeptideTweenInt
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.schemas.User
|
||||
import chat.peptide.composables.generic.UserAvatar
|
||||
|
||||
|
|
@ -41,15 +41,15 @@ fun StackedUserAvatars(
|
|||
.size(size + (offset * minOf(users.size, amount)), size)
|
||||
) {
|
||||
users.take(amount).forEachIndexed { index, userId ->
|
||||
val user = RevoltAPI.userCache[userId]
|
||||
val maybeMember = serverId?.let { RevoltAPI.members.getMember(serverId, userId) }
|
||||
val user = PeptideAPI.userCache[userId]
|
||||
val maybeMember = serverId?.let { PeptideAPI.members.getMember(serverId, userId) }
|
||||
|
||||
UserAvatar(
|
||||
avatar = user?.avatar,
|
||||
userId = userId,
|
||||
username = user?.let { User.resolveDefaultName(it) }
|
||||
?: stringResource(id = R.string.unknown),
|
||||
rawUrl = maybeMember?.avatar?.let { "${RevoltAPI.getCurrentFilesUrl()}/avatars/${it.id}" },
|
||||
rawUrl = maybeMember?.avatar?.let { "${PeptideAPI.getCurrentFilesUrl()}/avatars/${it.id}" },
|
||||
size = size,
|
||||
modifier = Modifier
|
||||
.offset(
|
||||
|
|
@ -74,13 +74,13 @@ fun TypingIndicator(users: List<String>, serverId: String?) {
|
|||
AnimatedVisibility(
|
||||
visible = users.isNotEmpty(),
|
||||
enter = slideInVertically(
|
||||
animationSpec = RevoltTweenInt,
|
||||
animationSpec = PeptideTweenInt,
|
||||
initialOffsetY = { it }
|
||||
) + fadeIn(animationSpec = RevoltTweenFloat),
|
||||
) + fadeIn(animationSpec = PeptideTweenFloat),
|
||||
exit = slideOutVertically(
|
||||
animationSpec = RevoltTweenInt,
|
||||
animationSpec = PeptideTweenInt,
|
||||
targetOffsetY = { it }
|
||||
) + fadeOut(animationSpec = RevoltTweenFloat)
|
||||
) + fadeOut(animationSpec = PeptideTweenFloat)
|
||||
) {
|
||||
Row(
|
||||
Modifier
|
||||
|
|
@ -94,9 +94,9 @@ fun TypingIndicator(users: List<String>, serverId: String?) {
|
|||
text = stringResource(
|
||||
id = typingMessageResource(),
|
||||
users.joinToString { userId ->
|
||||
RevoltAPI.userCache[userId]?.let { u ->
|
||||
PeptideAPI.userCache[userId]?.let { u ->
|
||||
val maybeMember =
|
||||
serverId?.let { RevoltAPI.members.getMember(serverId, userId) }
|
||||
serverId?.let { PeptideAPI.members.getMember(serverId, userId) }
|
||||
|
||||
maybeMember?.nickname ?: User.resolveDefaultName(u)
|
||||
} ?: userId
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.min
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.schemas.Channel
|
||||
import chat.peptide.api.schemas.Message
|
||||
import chat.peptide.api.settings.LoadedSettings
|
||||
|
|
@ -162,7 +162,7 @@ fun RegularMessage(
|
|||
}
|
||||
},
|
||||
onNameClick = {
|
||||
val author = message.author?.let { RevoltAPI.userCache[it] } ?: return@Message
|
||||
val author = message.author?.let { PeptideAPI.userCache[it] } ?: return@Message
|
||||
putTextAtCursorPosition("@${author.username}#${author.discriminator}")
|
||||
},
|
||||
canReply = true,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import androidx.compose.ui.unit.dp
|
|||
import androidx.core.graphics.toColorInt
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.routes.googlesheets.ServerData
|
||||
import chat.peptide.composables.generic.SquareButton
|
||||
|
||||
|
|
@ -104,7 +104,8 @@ fun DiscoverServersList(
|
|||
) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.padding(16.dp),
|
||||
color = MaterialTheme.colorScheme.secondary
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -165,8 +166,8 @@ fun DiscoverServersList(
|
|||
}
|
||||
|
||||
private fun isServerAlreadyJoined(serverId: String): Boolean {
|
||||
// Check if the server exists in RevoltAPI.serverCache
|
||||
return RevoltAPI.serverCache.containsKey(serverId)
|
||||
// Check if the server exists in PeptideAPI.serverCache
|
||||
return PeptideAPI.serverCache.containsKey(serverId)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
@ -262,12 +263,11 @@ fun ServerItem(
|
|||
.fillMaxSize()
|
||||
) {
|
||||
if (isJoined) {
|
||||
// Show tick icon with green background for joined servers
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(20.dp)
|
||||
.clip(CircleShape)
|
||||
.background(MaterialTheme.colorScheme.primary) // Green color
|
||||
.background(Color(0xFF43bf83))
|
||||
.align(Alignment.Center),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
|
|
@ -275,8 +275,9 @@ fun ServerItem(
|
|||
modifier = Modifier.size(16.dp),
|
||||
painter = painterResource(R.drawable.icn_check_24dp),
|
||||
contentDescription = "Already joined",
|
||||
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onPrimary)
|
||||
colorFilter = ColorFilter.tint(Color.White)
|
||||
)
|
||||
|
||||
}
|
||||
} else {
|
||||
// Show arrow icon for servers not joined yet
|
||||
|
|
@ -302,9 +303,9 @@ fun ServerItem(
|
|||
private fun ServerItemPreview() {
|
||||
val server = ServerData(
|
||||
id = "1",
|
||||
name = "Revolt Lounge",
|
||||
description = "The official Revolt server. Hang out, chat, and get help with Revolt.",
|
||||
inviteCode = "revolt",
|
||||
name = "Peptide Lounge",
|
||||
description = "The official Peptide server. Hang out, chat, and get help with Peptide.",
|
||||
inviteCode = "peptide",
|
||||
disabled = false,
|
||||
showColor = null
|
||||
)
|
||||
|
|
@ -321,9 +322,9 @@ private fun ServerItemPreview() {
|
|||
private fun ColorfulServerItemPreview() {
|
||||
val server = ServerData(
|
||||
id = "1",
|
||||
name = "Revolt Lounge",
|
||||
description = "The official Revolt server. Hang out, chat, and get help with Revolt.",
|
||||
inviteCode = "revolt",
|
||||
name = "Peptide Lounge",
|
||||
description = "The official Peptide server. Hang out, chat, and get help with Peptide.",
|
||||
inviteCode = "peptide",
|
||||
disabled = false,
|
||||
showColor = "#1591ea"
|
||||
)
|
||||
|
|
@ -341,9 +342,9 @@ private fun ColorfulServerItemPreview() {
|
|||
private fun JoinedServerItemPreview() {
|
||||
val server = ServerData(
|
||||
id = "1",
|
||||
name = "Revolt Lounge",
|
||||
description = "The official Revolt server. Hang out, chat, and get help with Revolt.",
|
||||
inviteCode = "revolt",
|
||||
name = "Peptide Lounge",
|
||||
description = "The official Peptide server. Hang out, chat, and get help with Peptide.",
|
||||
inviteCode = "peptide",
|
||||
disabled = false,
|
||||
showColor = null,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package chat.peptide.composables.screens.chat.discover
|
|||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.routes.googlesheets.ServerData
|
||||
import chat.peptide.api.routes.googlesheets.ServerDataRepository
|
||||
import chat.peptide.api.routes.invites.fetchInviteByCode
|
||||
|
|
@ -34,7 +34,7 @@ data class DiscoverUiState(
|
|||
val selectedInviteCode: String? = null,
|
||||
val processingServerId: String? = null,
|
||||
val loadedInviteData: Invite? = null,
|
||||
val loadedError: RevoltError? = null
|
||||
val loadedError: PeptideError? = null
|
||||
)
|
||||
|
||||
@HiltViewModel
|
||||
|
|
@ -108,7 +108,7 @@ class DiscoverServersListViewModel @Inject constructor(
|
|||
} catch (_: Exception) {
|
||||
updateState {
|
||||
it.copy(
|
||||
loadedError = RevoltError("Unknown"),
|
||||
loadedError = PeptideError("Unknown"),
|
||||
selectedInviteCode = inviteCode,
|
||||
processingServerId = null
|
||||
)
|
||||
|
|
@ -120,11 +120,11 @@ class DiscoverServersListViewModel @Inject constructor(
|
|||
/**
|
||||
* Join server without showing loading in the server list
|
||||
*/
|
||||
fun joinServerWithoutProcessingIndicator(inviteCode: String): Flow<RsResult<InviteJoined, RevoltError>> = flow {
|
||||
fun joinServerWithoutProcessingIndicator(inviteCode: String): Flow<RsResult<InviteJoined, PeptideError>> = flow {
|
||||
try {
|
||||
emit(joinInviteByCode(inviteCode))
|
||||
} catch (_: Exception) {
|
||||
emit(RsResult.err(RevoltError("Unknown")))
|
||||
emit(RsResult.err(PeptideError("Unknown")))
|
||||
}
|
||||
}.flowOn(Dispatchers.IO)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideError
|
||||
import chat.peptide.api.schemas.Invite
|
||||
import chat.peptide.composables.generic.IconPlaceholder
|
||||
import chat.peptide.composables.generic.RemoteImage
|
||||
|
|
@ -41,7 +41,7 @@ import chat.peptide.composables.generic.RemoteImage
|
|||
fun ServerInviteDialog(
|
||||
isLoading: Boolean,
|
||||
invite: Invite?,
|
||||
error: RevoltError?,
|
||||
error: PeptideError?,
|
||||
onJoinClick: () -> Unit,
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
|
|
@ -136,7 +136,7 @@ fun ServerInviteDialog(
|
|||
) {
|
||||
if (invite.serverIcon != null) {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/icons/${invite.serverIcon.id}/${invite.serverIcon.filename}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/icons/${invite.serverIcon.id}/${invite.serverIcon.filename}",
|
||||
allowAnimation = false,
|
||||
description = invite.serverName ?: stringResource(id = R.string.unknown),
|
||||
modifier = Modifier
|
||||
|
|
@ -190,7 +190,7 @@ fun ServerInviteDialog(
|
|||
) {
|
||||
if (invite.userAvatar != null) {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/avatars/${invite.userAvatar.id}/${invite.userAvatar.filename}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/avatars/${invite.userAvatar.id}/${invite.userAvatar.filename}",
|
||||
description = invite.userName,
|
||||
modifier = Modifier
|
||||
.size(24.dp)
|
||||
|
|
@ -246,7 +246,7 @@ fun ServerInviteDialogPreviewError() {
|
|||
ServerInviteDialog(
|
||||
isLoading = false,
|
||||
invite = null,
|
||||
error = RevoltError(type = "NotFound"),
|
||||
error = PeptideError(type = "NotFound"),
|
||||
onJoinClick = {},
|
||||
onDismiss = {}
|
||||
)
|
||||
|
|
@ -256,7 +256,7 @@ fun ServerInviteDialogPreviewError() {
|
|||
@Composable
|
||||
fun ServerInviteDialogPreviewSuccess() {
|
||||
val invite = Invite(
|
||||
serverName = "Revolt Test Server",
|
||||
serverName = "Peptide Test Server",
|
||||
serverIcon = null, // Replace with a real AutumnResource if needed for preview
|
||||
memberCount = 123,
|
||||
userName = "TestUser",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import chat.peptide.api.RevoltError
|
||||
import chat.peptide.api.PeptideError
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ fun ServerInviteHandler(
|
|||
val scope = rememberCoroutineScope()
|
||||
var isJoining by remember { mutableStateOf(false) }
|
||||
var showDialog by remember { mutableStateOf(true) }
|
||||
var error by remember { mutableStateOf<RevoltError?>(null) }
|
||||
var error by remember { mutableStateOf<PeptideError?>(null) }
|
||||
|
||||
// Get the UI state
|
||||
val uiState by viewModel.uiState.collectAsState()
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.CategorisedChannelList
|
||||
import chat.peptide.api.internals.ChannelUtils
|
||||
import chat.peptide.api.internals.DirectMessages
|
||||
|
|
@ -114,7 +114,7 @@ fun ChannelSideDrawer(
|
|||
modifier: Modifier = Modifier
|
||||
) {
|
||||
|
||||
val server = RevoltAPI.serverCache[currentServer]
|
||||
val server = PeptideAPI.serverCache[currentServer]
|
||||
val categorisedChannels = server?.let {
|
||||
ChannelUtils.categoriseServerFlat(it)
|
||||
}
|
||||
|
|
@ -157,12 +157,12 @@ fun ChannelSideDrawer(
|
|||
// - Sort the servers that are in the ordering using the ordering.
|
||||
// - Add the servers that aren't in the ordering to the end of the list.
|
||||
// - Sort the servers that aren't in the ordering by their ID (creation order).
|
||||
val serverList = ((RevoltAPI.serverCache.values.filter {
|
||||
val serverList = ((PeptideAPI.serverCache.values.filter {
|
||||
SyncedSettings.ordering.servers.contains(
|
||||
it.id
|
||||
)
|
||||
}
|
||||
.sortedBy { SyncedSettings.ordering.servers.indexOf(it.id) }) + (RevoltAPI.serverCache.values.filter {
|
||||
.sortedBy { SyncedSettings.ordering.servers.indexOf(it.id) }) + (PeptideAPI.serverCache.values.filter {
|
||||
!SyncedSettings.ordering.servers.contains(
|
||||
it.id
|
||||
)
|
||||
|
|
@ -243,7 +243,7 @@ fun ChannelSideDrawer(
|
|||
else -> {
|
||||
val partner =
|
||||
if (dm.channelType == ChannelType.DirectMessage) {
|
||||
RevoltAPI.userCache[
|
||||
PeptideAPI.userCache[
|
||||
ChannelUtils.resolveDMPartner(
|
||||
dm
|
||||
)
|
||||
|
|
@ -304,7 +304,8 @@ fun ChannelSideDrawer(
|
|||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.icn_explore_24dp),
|
||||
contentDescription = stringResource(R.string.discover_alt)
|
||||
contentDescription = stringResource(R.string.discover_alt),
|
||||
tint = MaterialTheme.colorScheme.onSecondaryContainer
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -323,7 +324,8 @@ fun ChannelSideDrawer(
|
|||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.icn_add_24dp),
|
||||
contentDescription = stringResource(R.string.server_plus_alt)
|
||||
contentDescription = stringResource(R.string.server_plus_alt),
|
||||
tint = MaterialTheme.colorScheme.onSecondaryContainer
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -334,7 +336,7 @@ fun ChannelSideDrawer(
|
|||
) {
|
||||
val serverInList = serverList[it]
|
||||
val serverHasUnread =
|
||||
serverInList.id?.let { srvId -> RevoltAPI.unreads.serverHasUnread(srvId) }
|
||||
serverInList.id?.let { srvId -> PeptideAPI.unreads.serverHasUnread(srvId) }
|
||||
?: false
|
||||
val leftIndicatorHeight = animateDpAsState(
|
||||
targetValue = if (serverInList.id == currentServer) 32.dp
|
||||
|
|
@ -369,7 +371,7 @@ fun ChannelSideDrawer(
|
|||
serverInList.id?.let { srvId -> navigateToServer(srvId) }
|
||||
}) {
|
||||
val icon = serverInList.icon?.id?.let { iconId ->
|
||||
"${RevoltAPI.getCurrentFilesUrl()}/icons/$iconId"
|
||||
"${PeptideAPI.getCurrentFilesUrl()}/icons/$iconId"
|
||||
}
|
||||
if (icon != null) {
|
||||
RemoteImage(
|
||||
|
|
@ -436,7 +438,7 @@ fun ChannelSideDrawer(
|
|||
) {
|
||||
if (server?.banner != null) {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/banners/${server.banner.id}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/banners/${server.banner.id}",
|
||||
description = null,
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier
|
||||
|
|
@ -480,7 +482,7 @@ fun ChannelSideDrawer(
|
|||
if (server?.flags has ServerFlags.Official) {
|
||||
Icon(
|
||||
painter = painterResource(
|
||||
id = R.drawable.ic_revolt_decagram_24dp
|
||||
id = R.drawable.ic_peptide_decagram_24dp
|
||||
),
|
||||
contentDescription = stringResource(
|
||||
R.string.server_flag_official
|
||||
|
|
@ -564,14 +566,14 @@ fun ChannelSideDrawer(
|
|||
onClick = {
|
||||
onDestinationChanged(ChatRouterDestination.Friends)
|
||||
},
|
||||
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||
contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
containerColor = MaterialTheme.colorScheme.secondary,
|
||||
contentColor = MaterialTheme.colorScheme.onSecondary,
|
||||
shape = CircleShape
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_new_message),
|
||||
contentDescription = stringResource(R.string.message_friends),
|
||||
tint = MaterialTheme.colorScheme.onPrimaryContainer
|
||||
tint = MaterialTheme.colorScheme.onSecondary
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -615,11 +617,11 @@ private fun DirectMessagesChannelListRendererPreview() {
|
|||
"user2_id" to User(id = "user2_id", username = "User Two", avatar = null, online = false)
|
||||
)
|
||||
|
||||
// Simulate RevoltAPI cache for preview
|
||||
RevoltAPI.channelCache.clear()
|
||||
mockChannels.forEach { RevoltAPI.channelCache[it.id!!] = it }
|
||||
RevoltAPI.userCache.clear()
|
||||
mockUsers.forEach { (id, user) -> RevoltAPI.userCache[id] = user }
|
||||
// Simulate PeptideAPI cache for preview
|
||||
PeptideAPI.channelCache.clear()
|
||||
mockChannels.forEach { PeptideAPI.channelCache[it.id!!] = it }
|
||||
PeptideAPI.userCache.clear()
|
||||
mockUsers.forEach { (id, user) -> PeptideAPI.userCache[id] = user }
|
||||
|
||||
|
||||
//ColumnScope is required for DirectMessagesChannelListRenderer, let's provide a dummy one
|
||||
|
|
@ -636,14 +638,14 @@ private fun DirectMessagesChannelListRendererPreview() {
|
|||
@Preview
|
||||
@Composable
|
||||
private fun DirectMessagesChannelListRendererEmptyPreview() {
|
||||
// Simulate RevoltAPI cache for preview - empty state
|
||||
RevoltAPI.channelCache.clear()
|
||||
RevoltAPI.channelCache["saved_notes_channel_id"] = Channel(
|
||||
// Simulate PeptideAPI cache for preview - empty state
|
||||
PeptideAPI.channelCache.clear()
|
||||
PeptideAPI.channelCache["saved_notes_channel_id"] = Channel(
|
||||
id = "saved_notes_channel_id",
|
||||
name = "Saved Messages",
|
||||
channelType = ChannelType.SavedMessages
|
||||
)
|
||||
RevoltAPI.userCache.clear()
|
||||
PeptideAPI.userCache.clear()
|
||||
|
||||
//ColumnScope is required for DirectMessagesChannelListRenderer, let's provide a dummy one
|
||||
Column(Modifier.background(MaterialTheme.colorScheme.surface)) {
|
||||
|
|
@ -664,7 +666,7 @@ private fun ColumnScope.DirectMessagesChannelListRenderer(
|
|||
onOpenChannelContextSheet: (String) -> Unit,
|
||||
) {
|
||||
val dmAbleChannels =
|
||||
RevoltAPI.channelCache.values
|
||||
PeptideAPI.channelCache.values
|
||||
.filter { it.channelType == ChannelType.DirectMessage || it.channelType == ChannelType.Group }
|
||||
.filter { if (it.channelType == ChannelType.DirectMessage) it.active == true else true }
|
||||
.sortedBy { it.lastMessageID ?: it.id }
|
||||
|
|
@ -677,7 +679,7 @@ private fun ColumnScope.DirectMessagesChannelListRenderer(
|
|||
.weight(1f)
|
||||
) {
|
||||
item(key = "saved_messages") {
|
||||
val notesChannel = RevoltAPI.channelCache.values.firstOrNull {
|
||||
val notesChannel = PeptideAPI.channelCache.values.firstOrNull {
|
||||
it.channelType == ChannelType.SavedMessages
|
||||
}
|
||||
|
||||
|
|
@ -756,7 +758,7 @@ private fun ColumnScope.DirectMessagesChannelListRenderer(
|
|||
|
||||
val partner =
|
||||
if (channel.channelType == ChannelType.DirectMessage) {
|
||||
RevoltAPI.userCache[
|
||||
PeptideAPI.userCache[
|
||||
ChannelUtils.resolveDMPartner(
|
||||
channel
|
||||
)
|
||||
|
|
@ -776,7 +778,7 @@ private fun ColumnScope.DirectMessagesChannelListRenderer(
|
|||
else -> false
|
||||
},
|
||||
hasUnread = channel.lastMessageID?.let { lastMessageID ->
|
||||
RevoltAPI.unreads.hasUnread(
|
||||
PeptideAPI.unreads.hasUnread(
|
||||
channel.id!!,
|
||||
lastMessageID,
|
||||
serverId = null
|
||||
|
|
@ -859,7 +861,7 @@ private fun ColumnScope.ServerChannelListRenderer(
|
|||
onDestinationChanged(dest)
|
||||
},
|
||||
hasUnread = channelOrCat.channel.lastMessageID?.let { lastMessageID ->
|
||||
RevoltAPI.unreads.hasUnread(
|
||||
PeptideAPI.unreads.hasUnread(
|
||||
channelOrCat.channel.id!!,
|
||||
lastMessageID,
|
||||
serverId
|
||||
|
|
@ -981,7 +983,7 @@ fun ChannelItem(
|
|||
Text(
|
||||
text = (ChannelUtils.resolveName(channel) ?: stringResource(R.string.unknown))
|
||||
+ if (appendServerName && channel.server != null) {
|
||||
" (${RevoltAPI.serverCache[channel.server]?.name ?: stringResource(R.string.unknown)})"
|
||||
" (${PeptideAPI.serverCache[channel.server]?.name ?: stringResource(R.string.unknown)})"
|
||||
} else {
|
||||
""
|
||||
},
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import androidx.compose.ui.draw.alpha
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import chat.peptide.activities.InviteActivity
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.buildUserAgent
|
||||
import chat.peptide.api.internals.ThemeCompat
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
|
@ -60,13 +60,13 @@ fun ColumnScope.DiscoverView() {
|
|||
super.onPageFinished(view, url)
|
||||
val themeMessage = JsonObject(
|
||||
mapOf(
|
||||
"source" to JsonPrimitive("revolt"),
|
||||
"source" to JsonPrimitive("peptide"),
|
||||
"type" to JsonPrimitive("theme"),
|
||||
"theme" to themeMap
|
||||
)
|
||||
)
|
||||
val themeMessageString =
|
||||
RevoltJson.encodeToString(JsonObject.serializer(), themeMessage)
|
||||
PeptideJson.encodeToString(JsonObject.serializer(), themeMessage)
|
||||
|
||||
evaluateJavascript(
|
||||
"""
|
||||
|
|
@ -101,7 +101,7 @@ fun ColumnScope.DiscoverView() {
|
|||
view: WebView?,
|
||||
request: WebResourceRequest?
|
||||
): Boolean {
|
||||
if (request?.url?.host.equals(Uri.parse(RevoltAPI.getCurrentAppUrl()).host)) {
|
||||
if (request?.url?.host.equals(Uri.parse(PeptideAPI.getCurrentAppUrl()).host)) {
|
||||
val intent = Intent(
|
||||
context,
|
||||
InviteActivity::class.java
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.schemas.Server
|
||||
import chat.peptide.api.schemas.ServerFlags
|
||||
import chat.peptide.api.schemas.has
|
||||
|
|
@ -51,7 +51,7 @@ fun ServerOverview(server: Server) {
|
|||
)
|
||||
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/banners/${it.id}/${it.filename}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/banners/${it.id}/${it.filename}",
|
||||
description = null,
|
||||
modifier = Modifier
|
||||
.height(166.dp)
|
||||
|
|
@ -80,7 +80,7 @@ fun ServerOverview(server: Server) {
|
|||
) {
|
||||
server.icon?.let {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/icons/${it.id}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/icons/${it.id}",
|
||||
description = null,
|
||||
allowAnimation = false,
|
||||
modifier = Modifier
|
||||
|
|
@ -104,7 +104,7 @@ fun ServerOverview(server: Server) {
|
|||
CompositionLocalProvider(LocalContentColor provides Color.White) {
|
||||
if (server.flags has ServerFlags.Official) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_revolt_decagram_24dp),
|
||||
painter = painterResource(id = R.drawable.ic_peptide_decagram_24dp),
|
||||
contentDescription = stringResource(R.string.server_flag_official),
|
||||
modifier = Modifier
|
||||
.padding(end = 8.dp)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.unit.dp
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.routes.user.acceptFriendRequest
|
||||
import chat.peptide.api.routes.user.blockUser
|
||||
import chat.peptide.api.routes.user.friendUser
|
||||
|
|
@ -155,8 +155,8 @@ fun UserButtons(
|
|||
scope.launch {
|
||||
val dm = openDM(user.id)
|
||||
if (dm.id != null) {
|
||||
if (RevoltAPI.channelCache[dm.id] == null)
|
||||
RevoltAPI.channelCache[dm.id] = dm
|
||||
if (PeptideAPI.channelCache[dm.id] == null)
|
||||
PeptideAPI.channelCache[dm.id] = dm
|
||||
ActionChannel.send(Action.SwitchChannel(dm.id))
|
||||
dismissSheet()
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import androidx.compose.ui.text.SpanStyle
|
|||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.SpecialUsers
|
||||
import chat.peptide.api.internals.ULID
|
||||
import chat.peptide.api.internals.solidColor
|
||||
|
|
@ -47,7 +47,7 @@ import kotlinx.coroutines.runBlocking
|
|||
|
||||
@Composable
|
||||
fun SelfUserOverview() {
|
||||
val selfUser = RevoltAPI.userCache[RevoltAPI.selfId] ?: return
|
||||
val selfUser = PeptideAPI.userCache[PeptideAPI.selfId] ?: return
|
||||
|
||||
UserOverview(selfUser)
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ fun RawUserOverview(
|
|||
if (background != null) {
|
||||
RemoteImage(
|
||||
url = backgroundUrl
|
||||
?: "${RevoltAPI.getCurrentFilesUrl()}/backgrounds/${if (background is AutumnResource) background.id else null}/${if (background is AutumnResource) background.filename else background}",
|
||||
?: "${PeptideAPI.getCurrentFilesUrl()}/backgrounds/${if (background is AutumnResource) background.id else null}/${if (background is AutumnResource) background.filename else background}",
|
||||
description = null,
|
||||
modifier = Modifier
|
||||
.height(128.dp)
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ import androidx.compose.ui.unit.dp
|
|||
const val HL_USERNAME = 0xFF4799F0
|
||||
const val HL_TAG = 0xFF3ABF7E
|
||||
|
||||
val RevoltTagIntro: ImageVector
|
||||
val PeptideTagIntro: ImageVector
|
||||
@Composable
|
||||
get() {
|
||||
if (_RevoltTagIntro != null) {
|
||||
return _RevoltTagIntro!!
|
||||
if (_PeptideTagIntro != null) {
|
||||
return _PeptideTagIntro!!
|
||||
}
|
||||
_RevoltTagIntro = ImageVector.Builder(
|
||||
name = "RevoltTagIntro",
|
||||
_PeptideTagIntro = ImageVector.Builder(
|
||||
name = "PeptideTagIntro",
|
||||
defaultWidth = 700.dp,
|
||||
defaultHeight = 412.dp,
|
||||
viewportWidth = 700f,
|
||||
|
|
@ -833,17 +833,17 @@ val RevoltTagIntro: ImageVector
|
|||
}
|
||||
}.build()
|
||||
|
||||
return _RevoltTagIntro!!
|
||||
return _PeptideTagIntro!!
|
||||
}
|
||||
|
||||
@Suppress("ObjectPropertyName")
|
||||
private var _RevoltTagIntro: ImageVector? = null
|
||||
private var _PeptideTagIntro: ImageVector? = null
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun RevoltTagIntroPreview() {
|
||||
fun PeptideTagIntroPreview() {
|
||||
Image(
|
||||
imageVector = RevoltTagIntro,
|
||||
imageVector = PeptideTagIntro,
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ import androidx.core.content.res.ResourcesCompat
|
|||
import androidx.webkit.WebViewAssetLoader
|
||||
import chat.peptide.R
|
||||
import chat.peptide.activities.InviteActivity
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.databinding.SheetChangelogBinding
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.google.android.material.color.MaterialColors
|
||||
|
|
@ -62,7 +62,7 @@ class ChangelogBottomSheetFragment(
|
|||
|
||||
binding.wvChangelog.apply {
|
||||
val assetLoader = WebViewAssetLoader.Builder()
|
||||
.setDomain(Uri.parse(RevoltAPI.getCurrentAppUrl()).host!!)
|
||||
.setDomain(Uri.parse(PeptideAPI.getCurrentAppUrl()).host!!)
|
||||
.addPathHandler(
|
||||
"/_android_assets/",
|
||||
WebViewAssetLoader.AssetsPathHandler(context)
|
||||
|
|
@ -89,7 +89,7 @@ class ChangelogBottomSheetFragment(
|
|||
// Capture clicks on invite links
|
||||
if (webResourceRequest.url.host == "rvlt.gg" ||
|
||||
(
|
||||
webResourceRequest.url.host?.endsWith("revolt.chat") == true && webResourceRequest.url.path?.startsWith(
|
||||
webResourceRequest.url.host?.endsWith("peptide.chat") == true && webResourceRequest.url.path?.startsWith(
|
||||
"/invite"
|
||||
) == true
|
||||
)
|
||||
|
|
@ -127,7 +127,7 @@ class ChangelogBottomSheetFragment(
|
|||
}
|
||||
|
||||
loadUrl(
|
||||
"${RevoltAPI.getCurrentAppUrl()}/_android_assets/changelogs/renderer.html"
|
||||
"${PeptideAPI.getCurrentAppUrl()}/_android_assets/changelogs/renderer.html"
|
||||
)
|
||||
|
||||
settings.apply {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package chat.peptide.internals
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.PermissionBit
|
||||
import chat.peptide.api.internals.Roles
|
||||
import chat.peptide.api.internals.has
|
||||
|
|
@ -23,7 +23,7 @@ object Autocomplete {
|
|||
}.distinctBy { it.shortcode }
|
||||
|
||||
val customResults =
|
||||
RevoltAPI.emojiCache.values.filter {
|
||||
PeptideAPI.emojiCache.values.filter {
|
||||
it.name?.contains(query, ignoreCase = true) ?: false
|
||||
}.mapNotNull {
|
||||
if (it.name != null) {
|
||||
|
|
@ -46,25 +46,25 @@ object Autocomplete {
|
|||
serverId: String? = null,
|
||||
query: String
|
||||
): List<AutocompleteSuggestion> {
|
||||
val channel = RevoltAPI.channelCache[channelId] ?: return emptyList()
|
||||
val channel = PeptideAPI.channelCache[channelId] ?: return emptyList()
|
||||
|
||||
val member = serverId?.let { RevoltAPI.members.getMember(serverId, RevoltAPI.selfId ?: "") }
|
||||
val member = serverId?.let { PeptideAPI.members.getMember(serverId, PeptideAPI.selfId ?: "") }
|
||||
val massMentionSuggestions = listOf("everyone", "online")
|
||||
.filter { it.startsWith(query, ignoreCase = true) }
|
||||
|
||||
val selfPermissions = RevoltAPI.channelCache[channelId]?.let { ch ->
|
||||
val selfPermissions = PeptideAPI.channelCache[channelId]?.let { ch ->
|
||||
Roles.permissionFor(
|
||||
ch,
|
||||
RevoltAPI.userCache[RevoltAPI.selfId],
|
||||
PeptideAPI.userCache[PeptideAPI.selfId],
|
||||
member
|
||||
)
|
||||
}
|
||||
|
||||
return when (channel.channelType) {
|
||||
ChannelType.DirectMessage -> {
|
||||
val otherUser = channel.recipients?.find { it != RevoltAPI.selfId }
|
||||
val otherUser = channel.recipients?.find { it != PeptideAPI.selfId }
|
||||
if (otherUser != null) {
|
||||
val user = RevoltAPI.userCache[otherUser]
|
||||
val user = PeptideAPI.userCache[otherUser]
|
||||
if (user != null && user.username?.contains(query, ignoreCase = true) == true) {
|
||||
listOf(
|
||||
AutocompleteSuggestion.User(
|
||||
|
|
@ -83,7 +83,7 @@ object Autocomplete {
|
|||
|
||||
ChannelType.Group -> {
|
||||
val users =
|
||||
channel.recipients?.mapNotNull { RevoltAPI.userCache[it] } ?: emptyList()
|
||||
channel.recipients?.mapNotNull { PeptideAPI.userCache[it] } ?: emptyList()
|
||||
users
|
||||
.filter { it.username?.contains(query, ignoreCase = true) ?: false }
|
||||
.map {
|
||||
|
|
@ -96,7 +96,7 @@ object Autocomplete {
|
|||
}
|
||||
|
||||
ChannelType.SavedMessages -> {
|
||||
val user = RevoltAPI.userCache[RevoltAPI.selfId]
|
||||
val user = PeptideAPI.userCache[PeptideAPI.selfId]
|
||||
return if (user != null && user.username?.contains(
|
||||
query,
|
||||
ignoreCase = true
|
||||
|
|
@ -119,22 +119,22 @@ object Autocomplete {
|
|||
if (query.length < 2) return emptyList()
|
||||
|
||||
val roles =
|
||||
if (selfPermissions has PermissionBit.MentionRoles && FeatureFlags.massMentionsGranted) RevoltAPI.serverCache[serverId]?.roles
|
||||
if (selfPermissions has PermissionBit.MentionRoles && FeatureFlags.massMentionsGranted) PeptideAPI.serverCache[serverId]?.roles
|
||||
?: emptyMap() else emptyMap()
|
||||
val byNickname = RevoltAPI.members.filterNamesFor(serverId, query)
|
||||
.map { m -> m to RevoltAPI.userCache[m.id?.user] }.filter { (_, u) ->
|
||||
val byNickname = PeptideAPI.members.filterNamesFor(serverId, query)
|
||||
.map { m -> m to PeptideAPI.userCache[m.id?.user] }.filter { (_, u) ->
|
||||
u != null
|
||||
}.map { (m, u) ->
|
||||
m to u!!
|
||||
}
|
||||
val byUsername = RevoltAPI.userCache.values.filter {
|
||||
val byUsername = PeptideAPI.userCache.values.filter {
|
||||
it.username?.contains(
|
||||
query,
|
||||
ignoreCase = true
|
||||
) == true
|
||||
}.mapNotNull {
|
||||
it.id?.let { _ ->
|
||||
RevoltAPI.members.getMember(
|
||||
PeptideAPI.members.getMember(
|
||||
serverId,
|
||||
it.id
|
||||
) to it
|
||||
|
|
@ -183,8 +183,8 @@ object Autocomplete {
|
|||
serverId: String,
|
||||
query: String
|
||||
): List<AutocompleteSuggestion.Channel> {
|
||||
val server = RevoltAPI.serverCache[serverId] ?: return emptyList()
|
||||
val channels = server.channels?.mapNotNull { RevoltAPI.channelCache[it] } ?: emptyList()
|
||||
val server = PeptideAPI.serverCache[serverId] ?: return emptyList()
|
||||
val channels = server.channels?.mapNotNull { PeptideAPI.channelCache[it] } ?: emptyList()
|
||||
|
||||
return channels.filter { it.name?.contains(query, ignoreCase = true) == true }.map {
|
||||
AutocompleteSuggestion.Channel(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package chat.peptide.internals
|
||||
|
||||
import android.content.Context
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.internals.IndexHolder.cachedIndex
|
||||
import chat.peptide.persistence.KVStorage
|
||||
import io.ktor.client.request.get
|
||||
|
|
@ -55,9 +55,9 @@ class Changelogs(val context: Context, val kvStorage: KVStorage? = null) {
|
|||
}
|
||||
|
||||
try {
|
||||
val response = RevoltHttp.get("${RevoltAPI.getCurrentKjBookUrl()}/changelogs.json")
|
||||
val response = PeptideHttp.get("${PeptideAPI.getCurrentKjBookUrl()}/changelogs.json")
|
||||
cachedIndex =
|
||||
RevoltJson.decodeFromString(ChangelogIndex.serializer(), response.bodyAsText())
|
||||
PeptideJson.decodeFromString(ChangelogIndex.serializer(), response.bodyAsText())
|
||||
return cachedIndex as ChangelogIndex
|
||||
} catch (e: Error) {
|
||||
return ChangelogIndex()
|
||||
|
|
@ -66,8 +66,8 @@ class Changelogs(val context: Context, val kvStorage: KVStorage? = null) {
|
|||
|
||||
suspend fun fetchChangelogByVersionCode(versionCode: Long): Changelog {
|
||||
try {
|
||||
val response = RevoltHttp.get("${RevoltAPI.getCurrentKjBookUrl()}/changelogs/$versionCode.json")
|
||||
return RevoltJson.decodeFromString(Changelog.serializer(), response.bodyAsText())
|
||||
val response = PeptideHttp.get("${PeptideAPI.getCurrentKjBookUrl()}/changelogs/$versionCode.json")
|
||||
return PeptideJson.decodeFromString(Changelog.serializer(), response.bodyAsText())
|
||||
} catch (e: Error) {
|
||||
return Changelog(
|
||||
id = "",
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ package chat.peptide.internals
|
|||
|
||||
import android.content.Context
|
||||
import chat.peptide.R
|
||||
import chat.peptide.RevoltApplication
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.PeptideApplication
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.schemas.Server
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
|
@ -68,11 +68,11 @@ class EmojiImpl {
|
|||
val json = context.assets.open("metadata/emoji.json").use {
|
||||
it.reader().readText()
|
||||
}
|
||||
return RevoltJson.decodeFromString(ListSerializer(EmojiGroup.serializer()), json)
|
||||
return PeptideJson.decodeFromString(ListSerializer(EmojiGroup.serializer()), json)
|
||||
}
|
||||
|
||||
fun serversWithEmotes(): List<Server> {
|
||||
return RevoltAPI
|
||||
return PeptideAPI
|
||||
.emojiCache
|
||||
.values
|
||||
.asSequence()
|
||||
|
|
@ -81,13 +81,13 @@ class EmojiImpl {
|
|||
.filter { it.type == "Server" }
|
||||
.map { it.id }
|
||||
.distinct()
|
||||
.mapNotNull { RevoltAPI.serverCache[it] }
|
||||
.mapNotNull { PeptideAPI.serverCache[it] }
|
||||
.toList()
|
||||
}
|
||||
|
||||
fun serverEmoteList(server: Server): List<EmojiPickerItem> {
|
||||
val list = mutableListOf<EmojiPickerItem>()
|
||||
val emotes = RevoltAPI.emojiCache.values.filter { it.parent?.id == server.id }
|
||||
val emotes = PeptideAPI.emojiCache.values.filter { it.parent?.id == server.id }
|
||||
|
||||
list.add(EmojiPickerItem.Section(Category.ServerEmoteCategory(server)))
|
||||
list.addAll(emotes.map { EmojiPickerItem.ServerEmote(it) })
|
||||
|
|
@ -149,7 +149,7 @@ class EmojiImpl {
|
|||
it is EmojiPickerItem.Section && it.category is Category.ServerEmoteCategory && it.category.server == server
|
||||
}
|
||||
val allEmotesInThatServer =
|
||||
RevoltAPI.emojiCache.values.filter { it.parent?.id == server.id }
|
||||
PeptideAPI.emojiCache.values.filter { it.parent?.id == server.id }
|
||||
val lastIndex = index + allEmotesInThatServer.size
|
||||
|
||||
output[Category.ServerEmoteCategory(server)] = Pair(index, lastIndex)
|
||||
|
|
@ -206,7 +206,7 @@ class EmojiImpl {
|
|||
val list = mutableListOf<EmojiPickerItem>()
|
||||
|
||||
for (server in serversWithEmotes()) {
|
||||
val emotes = RevoltAPI.emojiCache.values.filter { it.parent?.id == server.id }
|
||||
val emotes = PeptideAPI.emojiCache.values.filter { it.parent?.id == server.id }
|
||||
val matchingEmotes =
|
||||
emotes.filter { it.name?.contains(query, ignoreCase = true) ?: false }
|
||||
if (matchingEmotes.isNotEmpty()) {
|
||||
|
|
@ -290,6 +290,6 @@ class EmojiImpl {
|
|||
}
|
||||
|
||||
init {
|
||||
metadata = initMetadata(RevoltApplication.instance.applicationContext)
|
||||
metadata = initMetadata(PeptideApplication.instance.applicationContext)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import androidx.compose.runtime.LaunchedEffect
|
|||
import androidx.compose.runtime.MutableLongState
|
||||
import androidx.compose.runtime.mutableLongStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.Roles
|
||||
|
||||
@Composable
|
||||
|
|
@ -13,16 +13,16 @@ fun rememberChannelPermissions(channelId: String, key1: Any = Unit): MutableLong
|
|||
val permissions = rememberSaveable { mutableLongStateOf(0L) }
|
||||
|
||||
LaunchedEffect(channelId, key1) {
|
||||
if (RevoltAPI.selfId == null) return@LaunchedEffect
|
||||
if (RevoltAPI.userCache[RevoltAPI.selfId] == null) return@LaunchedEffect
|
||||
if (RevoltAPI.channelCache[channelId] == null) return@LaunchedEffect
|
||||
if (PeptideAPI.selfId == null) return@LaunchedEffect
|
||||
if (PeptideAPI.userCache[PeptideAPI.selfId] == null) return@LaunchedEffect
|
||||
if (PeptideAPI.channelCache[channelId] == null) return@LaunchedEffect
|
||||
|
||||
val channel = RevoltAPI.channelCache[channelId]
|
||||
val selfUser = RevoltAPI.userCache[RevoltAPI.selfId]
|
||||
val channel = PeptideAPI.channelCache[channelId]
|
||||
val selfUser = PeptideAPI.userCache[PeptideAPI.selfId]
|
||||
val member = channel?.let {
|
||||
it.server?.let { server ->
|
||||
RevoltAPI.selfId?.let { selfId ->
|
||||
RevoltAPI.members.getMember(server, selfId)
|
||||
PeptideAPI.selfId?.let { selfId ->
|
||||
PeptideAPI.members.getMember(server, selfId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package chat.peptide.internals.text
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.schemas.ChannelType
|
||||
import chat.peptide.internals.EmojiImpl
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ object MessageProcessor {
|
|||
?: return@fold acc
|
||||
|
||||
val user =
|
||||
RevoltAPI.userCache.values.find { it.username == username && it.discriminator == discriminator }
|
||||
PeptideAPI.userCache.values.find { it.username == username && it.discriminator == discriminator }
|
||||
|
||||
val userId = user?.id ?: return@fold acc
|
||||
acc.replace(mention, "<@$userId>")
|
||||
|
|
@ -38,7 +38,7 @@ object MessageProcessor {
|
|||
?: return@fold acc
|
||||
|
||||
val fetchedChannel =
|
||||
RevoltAPI.channelCache.values.find {
|
||||
PeptideAPI.channelCache.values.find {
|
||||
it.name == channelName && it.server == serverId && it.channelType == ChannelType.TextChannel
|
||||
}
|
||||
?: return@fold acc
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import androidx.compose.ui.graphics.toArgb
|
|||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import androidx.webkit.WebViewAssetLoader
|
||||
import chat.peptide.activities.InviteActivity
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.ResourceLocations
|
||||
import chat.peptide.markdown.jbm.LocalJBMarkdownTreeState
|
||||
import chat.peptide.markdown.jbm.MentionResolver
|
||||
|
|
@ -34,7 +34,7 @@ fun FallbackRenderer(content: String, modifier: Modifier = Modifier) {
|
|||
factory = { context ->
|
||||
WebView(context).apply {
|
||||
val assetLoader = WebViewAssetLoader.Builder()
|
||||
.setDomain(Uri.parse(RevoltAPI.getCurrentAppUrl()).host!!)
|
||||
.setDomain(Uri.parse(PeptideAPI.getCurrentAppUrl()).host!!)
|
||||
.addPathHandler(
|
||||
"/_android_assets/",
|
||||
WebViewAssetLoader.AssetsPathHandler(context)
|
||||
|
|
@ -61,7 +61,7 @@ fun FallbackRenderer(content: String, modifier: Modifier = Modifier) {
|
|||
// Capture clicks on invite links
|
||||
if (webResourceRequest.url.host == "rvlt.gg" ||
|
||||
(
|
||||
webResourceRequest.url.host?.endsWith("revolt.chat") == true && webResourceRequest.url.path?.startsWith(
|
||||
webResourceRequest.url.host?.endsWith("peptide.chat") == true && webResourceRequest.url.path?.startsWith(
|
||||
"/invite"
|
||||
) == true
|
||||
)
|
||||
|
|
@ -126,7 +126,7 @@ fun FallbackRenderer(content: String, modifier: Modifier = Modifier) {
|
|||
|
||||
@JavascriptInterface
|
||||
fun getCustomEmoteUrl(emoteId: String): String {
|
||||
return "${RevoltAPI.getCurrentFilesUrl()}/emojis/$emoteId/original"
|
||||
return "${PeptideAPI.getCurrentFilesUrl()}/emojis/$emoteId/original"
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
|
|
@ -136,7 +136,7 @@ fun FallbackRenderer(content: String, modifier: Modifier = Modifier) {
|
|||
|
||||
@JavascriptInterface
|
||||
fun userAvatar(userId: String): String {
|
||||
return ResourceLocations.userAvatarUrl(RevoltAPI.userCache[userId])
|
||||
return ResourceLocations.userAvatarUrl(PeptideAPI.userCache[userId])
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
|
|
@ -149,7 +149,7 @@ fun FallbackRenderer(content: String, modifier: Modifier = Modifier) {
|
|||
setBackgroundColor(android.graphics.Color.TRANSPARENT)
|
||||
|
||||
loadUrl(
|
||||
"${RevoltAPI.getCurrentAppUrl()}/_android_assets/markdown/markdown.html"
|
||||
"${PeptideAPI.getCurrentAppUrl()}/_android_assets/markdown/markdown.html"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ import androidx.compose.ui.unit.sp
|
|||
import androidx.core.net.toUri
|
||||
import chat.peptide.R
|
||||
import chat.peptide.activities.InviteActivity
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.internals.BrushCompat
|
||||
import chat.peptide.api.internals.InstancedBrushCompat
|
||||
import chat.peptide.api.internals.isUlid
|
||||
|
|
@ -267,7 +267,7 @@ private fun annotateText(
|
|||
append(annotateText(state, child))
|
||||
}
|
||||
} else {
|
||||
val server = RevoltAPI.serverCache[state.currentServer]
|
||||
val server = PeptideAPI.serverCache[state.currentServer]
|
||||
val role = server?.roles?.get(roleId)
|
||||
val isGradient = role?.colour?.contains("gradient") == true
|
||||
|
||||
|
|
@ -722,7 +722,7 @@ private fun JBMText(node: ASTNode, modifier: Modifier) {
|
|||
placeholderVerticalAlign = PlaceholderVerticalAlign.Center
|
||||
),
|
||||
) { id ->
|
||||
val role = RevoltAPI.serverCache[mdState.currentServer]?.roles?.get(id)
|
||||
val role = PeptideAPI.serverCache[mdState.currentServer]?.roles?.get(id)
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier
|
||||
|
|
@ -748,11 +748,11 @@ private fun JBMText(node: ASTNode, modifier: Modifier) {
|
|||
placeholderVerticalAlign = PlaceholderVerticalAlign.Center
|
||||
),
|
||||
) { id ->
|
||||
val emote = RevoltAPI.emojiCache[id]
|
||||
val emote = PeptideAPI.emojiCache[id]
|
||||
if (emote == null) {
|
||||
scope.launch {
|
||||
try {
|
||||
RevoltAPI.emojiCache[id] = fetchEmoji(id)
|
||||
PeptideAPI.emojiCache[id] = fetchEmoji(id)
|
||||
} catch (e: Exception) {
|
||||
// no-op
|
||||
}
|
||||
|
|
@ -761,7 +761,7 @@ private fun JBMText(node: ASTNode, modifier: Modifier) {
|
|||
} else {
|
||||
with(LocalDensity.current) {
|
||||
RemoteImage(
|
||||
url = "${RevoltAPI.getCurrentFilesUrl()}/emojis/${id}",
|
||||
url = "${PeptideAPI.getCurrentFilesUrl()}/emojis/${id}",
|
||||
description = emote.name,
|
||||
contentScale = ContentScale.Fit,
|
||||
modifier = Modifier
|
||||
|
|
@ -786,7 +786,7 @@ private fun JBMText(node: ASTNode, modifier: Modifier) {
|
|||
placeholderVerticalAlign = PlaceholderVerticalAlign.Center
|
||||
),
|
||||
) { id ->
|
||||
val user = RevoltAPI.userCache[id]
|
||||
val user = PeptideAPI.userCache[id]
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import androidx.compose.ui.graphics.toArgb
|
|||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import androidx.webkit.WebViewAssetLoader
|
||||
import chat.peptide.activities.InviteActivity
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
|
||||
internal fun Color.asHexString(includeAlphaComponent: Boolean = true): String {
|
||||
val argb = toArgb()
|
||||
|
|
@ -46,7 +46,7 @@ fun KatexRenderer(content: String, modifier: Modifier = Modifier) {
|
|||
factory = { context ->
|
||||
WebView(context).apply {
|
||||
val assetLoader = WebViewAssetLoader.Builder()
|
||||
.setDomain(Uri.parse(RevoltAPI.getCurrentAppUrl()).host!!)
|
||||
.setDomain(Uri.parse(PeptideAPI.getCurrentAppUrl()).host!!)
|
||||
.addPathHandler(
|
||||
"/_android_assets/",
|
||||
WebViewAssetLoader.AssetsPathHandler(context)
|
||||
|
|
@ -73,7 +73,7 @@ fun KatexRenderer(content: String, modifier: Modifier = Modifier) {
|
|||
// Capture clicks on invite links
|
||||
if (webResourceRequest.url.host == "rvlt.gg" ||
|
||||
(
|
||||
webResourceRequest.url.host?.endsWith("revolt.chat") == true && webResourceRequest.url.path?.startsWith(
|
||||
webResourceRequest.url.host?.endsWith("peptide.chat") == true && webResourceRequest.url.path?.startsWith(
|
||||
"/invite"
|
||||
) == true
|
||||
)
|
||||
|
|
@ -131,7 +131,7 @@ fun KatexRenderer(content: String, modifier: Modifier = Modifier) {
|
|||
setBackgroundColor(android.graphics.Color.TRANSPARENT)
|
||||
|
||||
loadUrl(
|
||||
"${RevoltAPI.getCurrentAppUrl()}/_android_assets/katex/katex.html"
|
||||
"${PeptideAPI.getCurrentAppUrl()}/_android_assets/katex/katex.html"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package chat.peptide.markdown.jbm
|
||||
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.PeptideAPI
|
||||
|
||||
object MentionResolver {
|
||||
/**
|
||||
|
|
@ -12,9 +12,9 @@ object MentionResolver {
|
|||
* @return The resolved user mention.
|
||||
*/
|
||||
fun resolveUser(userId: String, serverId: String? = null): String {
|
||||
val maybeMember = serverId?.let { RevoltAPI.members.getMember(serverId, userId) }
|
||||
val maybeMember = serverId?.let { PeptideAPI.members.getMember(serverId, userId) }
|
||||
return maybeMember?.nickname
|
||||
?: RevoltAPI.userCache[userId]?.username
|
||||
?: PeptideAPI.userCache[userId]?.username
|
||||
?: "<@$userId>"
|
||||
}
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ object MentionResolver {
|
|||
* @return The resolved channel mention.
|
||||
*/
|
||||
fun resolveChannel(channelId: String): String {
|
||||
val channel = RevoltAPI.channelCache[channelId]
|
||||
val channel = PeptideAPI.channelCache[channelId]
|
||||
return channel?.name?.let { name -> "#$name" } ?: "<#$channelId>"
|
||||
}
|
||||
}
|
||||
|
|
@ -11,13 +11,13 @@ import kotlinx.coroutines.flow.firstOrNull
|
|||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
val Context.revoltKVStorage: DataStore<Preferences> by preferencesDataStore(name = "revolt_kv")
|
||||
val Context.peptideKVStorage: DataStore<Preferences> by preferencesDataStore(name = "peptide_kv")
|
||||
|
||||
@Singleton
|
||||
class KVStorage @Inject constructor(
|
||||
@ApplicationContext private val mContext: Context
|
||||
) {
|
||||
private val dataStore = mContext.revoltKVStorage
|
||||
private val dataStore = mContext.peptideKVStorage
|
||||
|
||||
suspend fun set(key: String, value: String) {
|
||||
dataStore.edit { preferences ->
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ package chat.peptide.persistence
|
|||
|
||||
import app.cash.sqldelight.db.SqlDriver
|
||||
import app.cash.sqldelight.driver.android.AndroidSqliteDriver
|
||||
import chat.peptide.RevoltApplication
|
||||
import chat.peptide.PeptideApplication
|
||||
|
||||
object SqlStorage {
|
||||
val driver: SqlDriver = AndroidSqliteDriver(
|
||||
Database.Schema,
|
||||
RevoltApplication.instance.applicationContext,
|
||||
"revolt.db"
|
||||
PeptideApplication.instance.applicationContext,
|
||||
"peptide.db"
|
||||
)
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ import android.net.Uri
|
|||
import androidx.core.content.FileProvider
|
||||
import chat.peptide.BuildConfig
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltHttp
|
||||
import chat.peptide.api.PeptideHttp
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.statement.readBytes
|
||||
import java.io.File
|
||||
|
|
@ -23,7 +23,7 @@ suspend fun getAttachmentContentUri(
|
|||
attachmentsDir.mkdir()
|
||||
}
|
||||
|
||||
val response = RevoltHttp.get(resourceUrl)
|
||||
val response = PeptideHttp.get(resourceUrl)
|
||||
val file = File(attachmentsDir, "$id-$filename")
|
||||
file.writeBytes(response.readBytes())
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.navigation.NavController
|
||||
import chat.peptide.RevoltApplication
|
||||
import chat.peptide.PeptideApplication
|
||||
import chat.peptide.api.internals.getComponentActivity
|
||||
import chat.peptide.composables.screens.splash.DisconnectedScreen
|
||||
import com.google.android.material.color.DynamicColors
|
||||
|
|
@ -39,7 +39,7 @@ fun DefaultDestinationScreen(
|
|||
// See the other one in MainActivity.kt
|
||||
val activity = context.getComponentActivity() as Activity
|
||||
DynamicColors.applyToActivityIfAvailable(activity)
|
||||
DynamicColors.applyToActivitiesIfAvailable(RevoltApplication.instance)
|
||||
DynamicColors.applyToActivitiesIfAvailable(PeptideApplication.instance)
|
||||
activity.window.statusBarColor = Color.Transparent.toArgb()
|
||||
|
||||
navController.popBackStack(navController.graph.startDestinationRoute!!, true)
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ import androidx.compose.foundation.layout.height
|
|||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ElevatedButton
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
|
|
@ -53,8 +51,8 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
|||
import androidx.navigation.NavController
|
||||
import chat.peptide.BuildConfig
|
||||
import chat.peptide.R
|
||||
import chat.peptide.api.RevoltAPI
|
||||
import chat.peptide.api.RevoltJson
|
||||
import chat.peptide.api.PeptideAPI
|
||||
import chat.peptide.api.PeptideJson
|
||||
import chat.peptide.api.routes.misc.Root
|
||||
import chat.peptide.api.routes.misc.getRootRoute
|
||||
import chat.peptide.composables.generic.PrimaryTabs
|
||||
|
|
@ -72,8 +70,8 @@ class AboutViewModel : ViewModel() {
|
|||
"App ID" to BuildConfig.APPLICATION_ID,
|
||||
"App Version" to BuildConfig.VERSION_NAME,
|
||||
"App Type" to BuildConfig.FLAVOUR_ID,
|
||||
"API Host" to URI(RevoltAPI.getCurrentBaseUrl()).host,
|
||||
"API Version" to (root?.revolt ?: "Unknown"),
|
||||
"API Host" to URI(PeptideAPI.getCurrentBaseUrl()).host,
|
||||
"API Version" to (root?.peptide ?: "Unknown"),
|
||||
"Runtime SDK" to Build.VERSION.SDK_INT.toString(),
|
||||
"Model" to "${Build.MANUFACTURER} ${
|
||||
Build.DEVICE.replaceFirstChar {
|
||||
|
|
@ -143,7 +141,7 @@ fun AboutScreen(navController: NavController, viewModel: AboutViewModel = viewMo
|
|||
|
||||
fun copyDebugInformation() {
|
||||
clipboardManager.setText(
|
||||
AnnotatedString(RevoltJson.encodeToString(viewModel.getDebugInformation()))
|
||||
AnnotatedString(PeptideJson.encodeToString(viewModel.getDebugInformation()))
|
||||
)
|
||||
|
||||
if (Platform.needsShowClipboardNotification()) {
|
||||
|
|
@ -211,7 +209,7 @@ fun AboutScreen(navController: NavController, viewModel: AboutViewModel = viewMo
|
|||
when (viewModel.selectedTabIndex) {
|
||||
0 -> {
|
||||
Image(
|
||||
painter = painterResource(R.drawable.revolt_logo_wide),
|
||||
painter = painterResource(R.drawable.peptide_logo_wide),
|
||||
contentDescription = stringResource(R.string.about_full_name),
|
||||
colorFilter = ColorFilter.tint(LocalContentColor.current),
|
||||
modifier = Modifier
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue