Skip to content

Commit

Permalink
Fix canceled event detection
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarX committed Jun 5, 2024
1 parent aafc8c5 commit e1e9448
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ object RealmDatabase {
//region Configurations versions
const val USER_INFO_SCHEMA_VERSION = 1L
const val MAILBOX_INFO_SCHEMA_VERSION = 5L
const val MAILBOX_CONTENT_SCHEMA_VERSION = 12L
const val MAILBOX_CONTENT_SCHEMA_VERSION = 13L
//endregion

//region Configurations names
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.infomaniak.mail.data.models.calendar

import com.infomaniak.lib.core.utils.Utils
import com.infomaniak.mail.data.api.CalendarRealmInstantSerializer
import com.infomaniak.mail.utils.extensions.toRealmInstant
import io.realm.kotlin.ext.realmListOf
Expand Down Expand Up @@ -46,8 +47,12 @@ class CalendarEvent() : EmbeddedRealmObject {
var start: RealmInstant = Date(0).toRealmInstant()
var end: RealmInstant = Date(0).toRealmInstant()
var attendees: RealmList<Attendee> = realmListOf()
@SerialName("status")
private var _status: String? = null
//endregion

val status: CalendarEventStatus? get() = Utils.enumValueOfOrNull<CalendarEventStatus>(_status)

constructor(
id: Int,
type: String,
Expand Down Expand Up @@ -76,6 +81,7 @@ class CalendarEvent() : EmbeddedRealmObject {
if (location != other.location) return false
if (isFullDay != other.isFullDay) return false
if (start != other.start) return false
if (_status != other._status) return false

return end == other.end
}
Expand All @@ -96,8 +102,15 @@ class CalendarEvent() : EmbeddedRealmObject {
result = 31 * result + isFullDay.hashCode()
result = 31 * result + start.hashCode()
result = 31 * result + end.hashCode()
result = 31 * result + _status.hashCode()
result = 31 * result + attendees.hashCode()

return result
}

enum class CalendarEventStatus(val apiValue: String) {
CONFIRMED("CONFIRMED"),
TENTATIVE("TENTATIVE"),
CANCELLED("CANCELLED"),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.infomaniak.mail.data.models.calendar

import com.infomaniak.lib.core.utils.Utils
import com.infomaniak.mail.data.models.calendar.CalendarEvent.CalendarEventStatus
import com.infomaniak.mail.utils.extensions.isUserIn
import io.realm.kotlin.types.EmbeddedRealmObject
import kotlinx.serialization.SerialName
Expand Down Expand Up @@ -54,7 +55,7 @@ class CalendarEventResponse() : EmbeddedRealmObject {

val calendarEvent get() = userStoredEvent ?: attachmentEvent

val isCanceled get() = isUserStoredEventDeleted || attachmentEventMethod == AttachmentEventMethod.CANCEL
val isCanceled get() = calendarEvent?.status == CalendarEventStatus.CANCELLED

fun isReplyAuthorized(): Boolean {
return (attachmentEventMethod == null || attachmentEventMethod == AttachmentEventMethod.REQUEST)
Expand Down

0 comments on commit e1e9448

Please sign in to comment.