Fix sending messages

(cherry picked from commit 88111ea725)
This commit is contained in:
Mikołaj Pich 2021-05-21 11:12:50 +02:00
parent c918ba39f4
commit 7a16f07bc8
3 changed files with 35 additions and 8 deletions

View file

@ -6,8 +6,11 @@ import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class SendMessageRequest(
@Json(name = "incoming")
val incoming: Incoming,
@Json(name = "incomming")
val incoming: Incoming
val incomming: Incoming, // for compatibility sake
) {

View file

@ -91,14 +91,15 @@ class MessagesRepository(private val api: MessagesService) {
logger.debug("Subject length: ${subject.length}, content length: ${content.length}, recipients number: ${recipients.size}")
val res = api.getStart()
logger.debug("Start page length: ${res.length}")
val incoming = SendMessageRequest.Incoming(
recipients = recipients,
subject = subject,
content = content
)
return api.sendMessage(
sendMessageRequest = SendMessageRequest(
SendMessageRequest.Incoming(
recipients = recipients,
subject = subject,
content = content
)
),
sendMessageRequest = SendMessageRequest(incoming, incoming),
token = getScriptParam("antiForgeryToken", res).ifBlank { throw ScrapperException("Can't find antiForgeryToken property!") },
appGuid = getScriptParam("appGuid", res),
appVersion = getScriptParam("version", res)

View file

@ -1,4 +1,27 @@
{
"incoming": {
"Adresaci": [
{
"Id": "0",
"Name": "Kowalski Jan",
"IdLogin": 0,
"UnitId": 0,
"Role": 2,
"Hash": "hash"
}
],
"Id": 0,
"Nadawca": {
"Id": null,
"Name": null,
"IdLogin": null,
"UnitId": null,
"Role": null,
"Hash": null
},
"Temat": "Temat wiadomości",
"Tresc": "Tak wygląda zawartość wiadomości.\nZazwyczaj ma wiele linijek.\n\nZ poważaniem,\nNazwisko Imię"
},
"incomming": {
"Adresaci": [
{