fix: stabler reconnect, fix message reporting

This commit is contained in:
Infi 2023-02-24 20:16:52 +01:00
parent c38fc51e23
commit 40b85aa880
3 changed files with 14 additions and 4 deletions

View File

@ -33,6 +33,13 @@ object RealtimeSocket {
}
suspend fun connect(token: String) {
if (disconnectionState == DisconnectionState.Connected) {
Log.d("RealtimeSocket", "Already connected to websocket. Refusing to connect again.")
return
}
socket?.close(CloseReason(CloseReason.Codes.NORMAL, "Reconnecting to websocket."))
RevoltHttp.ws(REVOLT_WEBSOCKET) {
socket = this

View File

@ -16,8 +16,9 @@ suspend fun putMessageReport(
) {
val fullMessageReport = FullMessageReport(
content = MessageReport(
type = "Message",
report_reason = reason,
id = messageId,
id = messageId
),
additional_context = additionalContext,
)
@ -48,6 +49,7 @@ suspend fun putServerReport(
) {
val fullServerReport = FullServerReport(
content = ServerReport(
type = "Server",
report_reason = reason,
id = serverId,
),
@ -80,6 +82,7 @@ suspend fun putUserReport(
) {
val fullUserReport = FullUserReport(
content = UserReport(
type = "User",
report_reason = reason,
id = userId,
),

View File

@ -80,7 +80,7 @@ enum class UserReportReason(val value: String) {
@Serializable
data class MessageReport(
val type: String = "Message",
val type: String,
val id: String,
val report_reason: ContentReportReason,
)
@ -93,7 +93,7 @@ data class FullMessageReport(
@Serializable
data class ServerReport(
val type: String = "Server",
val type: String,
val id: String,
val report_reason: ContentReportReason,
)
@ -106,7 +106,7 @@ data class FullServerReport(
@Serializable
data class UserReport(
val type: String = "User",
val type: String,
val id: String,
val report_reason: UserReportReason,
)