diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Chat.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Chat.kt new file mode 100644 index 00000000..980aaccc --- /dev/null +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Chat.kt @@ -0,0 +1,42 @@ +/* Copyright 2020 Alibek Omarov + * + * This file is a part of Husky. + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Husky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Husky; if not, + * see . */ + +package com.keylesspalace.tusky.entity + +import com.google.gson.annotations.SerializedName +import java.util.* + +data class ChatMessage( + val id: String, + val content: String, + @SerializedName("chat_id") val chatId: String, + @SerializedName("account_id") val accountId: String, + @SerializedName("created_at") val createdAt: Date, + val attachment: Attachment?, + val emojis: List +) + +data class Chat( + val account: Account, + val id: String, + val unread: Int, + @SerializedName("last_message") val lastMessage: ChatMessage?, + @SerializedName("updated_at") val updatedAt: Date +) + +data class NewChatMessage( + val content: String, + val media_id: String +) \ No newline at end of file diff --git a/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt index 2b1531f4..cf26c992 100644 --- a/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt +++ b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt @@ -622,4 +622,57 @@ interface MastodonApi { @Url path: String ): Single> // NOT AN API CALLS NOT AN API CALLS NOT AN API CALLS NOT AN API CALLS + + @POST("api/v1/pleroma/chats/{id}/messages/{message_id}/read") + fun markChatMessageAsRead( + @Path("id") chatId: String, + @Path("message_id") messageId: String + ): Single + + @DELETE("api/v1/pleroma/chats/{id}/messages/{message_id}") + fun deleteChatMessage( + @Path("id") chatId: String, + @Path("message_id") messageId: String + ): Single + + @GET("api/v1/pleroma/chats") + fun getChats( + @Query("max_id") maxId: String?, + @Query("min_id") minId: String?, + @Query("since_id") sinceId: String?, + @Query("offset") offset: Int?, + @Query("limit") limit: Int? + ): Single> + + @GET("api/v1/pleroma/chats/{id}/messages") + fun getChatMessages( + @Path("id") chatId: String, + @Query("max_id") maxId: String?, + @Query("min_id") minId: String?, + @Query("since_id") sinceId: String?, + @Query("offset") offset: Int?, + @Query("limit") limit: Int? + ): Single> + + @POST("api/v1/pleroma/chats/{id}/messages") + fun createChatMessage( + @Path("id") chatId: String, + @Body chatMessage: NewChatMessage + ): Single + + @POST("api/v1/pleroma/chats/{id}/read") + fun markChatAsRead( + @Path("id") chatId: String, + @Field("last_read_id") lastReadId: String + ): Single + + @POST("api/v1/pleroma/chats/by-account-id/{id}") + fun createChat( + @Path("id") accountId: String + ): Single + + @GET("api/v1/pleroma/chats/{id}") + fun getChat( + @Path("id") chatId: String + ): Single }