Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ import io.getstream.chat.android.client.api2.model.dto.MessageReadEventDto
import io.getstream.chat.android.client.api2.model.dto.MessageUpdatedEventDto
import io.getstream.chat.android.client.api2.model.dto.NewMessageEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationAddedToChannelEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationChannelDeletedEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationChannelMutesUpdatedEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationChannelTruncatedEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationInviteAcceptedEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationInviteRejectedEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationInvitedEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationMarkReadEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationMarkUnreadEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationMutesUpdatedEventDto
Expand Down Expand Up @@ -140,6 +135,11 @@ import io.getstream.chat.android.network.models.WSEvent
import io.getstream.chat.android.network.models.MemberAddedEvent as GeneratedMemberAddedEvent
import io.getstream.chat.android.network.models.MemberRemovedEvent as GeneratedMemberRemovedEvent
import io.getstream.chat.android.network.models.MemberUpdatedEvent as GeneratedMemberUpdatedEvent
import io.getstream.chat.android.network.models.NotificationChannelDeletedEvent as GeneratedNotificationChannelDeletedEvent
import io.getstream.chat.android.network.models.NotificationChannelTruncatedEvent as GeneratedNotificationChannelTruncatedEvent
import io.getstream.chat.android.network.models.NotificationInviteAcceptedEvent as GeneratedNotificationInviteAcceptedEvent
import io.getstream.chat.android.network.models.NotificationInviteRejectedEvent as GeneratedNotificationInviteRejectedEvent
import io.getstream.chat.android.network.models.NotificationInvitedEvent as GeneratedNotificationInvitedEvent
import io.getstream.chat.android.network.models.NotificationNewMessageEvent as GeneratedNotificationNewMessageEvent
import io.getstream.chat.android.network.models.PollClosedEvent as GeneratedPollClosedEvent
import io.getstream.chat.android.network.models.PollDeletedEvent as GeneratedPollDeletedEvent
Expand Down Expand Up @@ -194,12 +194,7 @@ internal class EventMapping(
is MessageReadEventDto -> toDomain()
is MessageUpdatedEventDto -> toDomain()
is NotificationAddedToChannelEventDto -> toDomain()
is NotificationChannelDeletedEventDto -> toDomain()
is NotificationChannelMutesUpdatedEventDto -> toDomain()
is NotificationChannelTruncatedEventDto -> toDomain()
is NotificationInviteAcceptedEventDto -> toDomain()
is NotificationInviteRejectedEventDto -> toDomain()
is NotificationInvitedEventDto -> toDomain()
is NotificationMarkReadEventDto -> toDomain()
is NotificationMarkUnreadEventDto -> toDomain()
is NotificationThreadMessageNewEventDto -> toDomain()
Expand Down Expand Up @@ -446,24 +441,6 @@ internal class EventMapping(
)
}

/**
* Transforms [NotificationChannelDeletedEventDto] to [NotificationChannelDeletedEvent].
*/
private fun NotificationChannelDeletedEventDto.toDomain(): NotificationChannelDeletedEvent = with(domainMapping) {
NotificationChannelDeletedEvent(
type = type,
createdAt = created_at.date,
rawCreatedAt = created_at.rawDate,
cid = cid,
channelType = channel_type,
channelId = channel_id,
channel = channel.toDomain(),
totalUnreadCount = total_unread_count,
unreadChannels = unread_channels,
groupedUnreadChannels = grouped_unread_channels,
)
}

/**
* Transforms [NotificationChannelMutesUpdatedEventDto] to [NotificationChannelMutesUpdatedEvent].
*/
Expand All @@ -477,75 +454,6 @@ internal class EventMapping(
)
}

/**
* Transforms [NotificationChannelTruncatedEventDto] to [NotificationChannelTruncatedEvent].
*/
private fun NotificationChannelTruncatedEventDto.toDomain(): NotificationChannelTruncatedEvent =
with(domainMapping) {
NotificationChannelTruncatedEvent(
type = type,
createdAt = created_at.date,
rawCreatedAt = created_at.rawDate,
cid = cid,
channelType = channel_type,
channelId = channel_id,
channel = channel.toDomain(),
totalUnreadCount = total_unread_count,
unreadChannels = unread_channels,
groupedUnreadChannels = grouped_unread_channels,
)
}

/**
* Transforms [NotificationInviteAcceptedEventDto] to [NotificationInviteAcceptedEvent].
*/
private fun NotificationInviteAcceptedEventDto.toDomain(): NotificationInviteAcceptedEvent = with(domainMapping) {
NotificationInviteAcceptedEvent(
type = type,
createdAt = created_at.date,
rawCreatedAt = created_at.rawDate,
cid = cid,
channelType = channel_type,
channelId = channel_id,
user = user.toDomain(),
member = member.toDomain(),
channel = channel.toDomain(),
)
}

/**
* Transforms [NotificationInviteRejectedEventDto] to [NotificationInviteRejectedEvent].
*/
private fun NotificationInviteRejectedEventDto.toDomain(): NotificationInviteRejectedEvent = with(domainMapping) {
NotificationInviteRejectedEvent(
type = type,
createdAt = created_at.date,
rawCreatedAt = created_at.rawDate,
cid = cid,
channelType = channel_type,
channelId = channel_id,
user = user.toDomain(),
member = member.toDomain(),
channel = channel.toDomain(),
)
}

/**
* Transforms [NotificationInvitedEventDto] to [NotificationInvitedEvent].
*/
private fun NotificationInvitedEventDto.toDomain(): NotificationInvitedEvent = with(domainMapping) {
NotificationInvitedEvent(
type = type,
createdAt = created_at.date,
rawCreatedAt = created_at.rawDate,
cid = cid,
channelType = channel_type,
channelId = channel_id,
user = user.toDomain(),
member = member.toDomain(),
)
}

/**
* Transforms [NotificationMarkReadEventDto] to [NotificationMarkReadEvent].
*/
Expand Down Expand Up @@ -781,6 +689,11 @@ internal class EventMapping(
is GeneratedMemberUpdatedEvent -> toDomain()
is GeneratedTypingStartEvent -> toDomain()
is GeneratedTypingStopEvent -> toDomain()
is GeneratedNotificationInvitedEvent -> toDomain()
is GeneratedNotificationInviteAcceptedEvent -> toDomain()
is GeneratedNotificationInviteRejectedEvent -> toDomain()
is GeneratedNotificationChannelDeletedEvent -> toDomain()
is GeneratedNotificationChannelTruncatedEvent -> toDomain()
is GeneratedPollClosedEvent -> toDomain()
is GeneratedPollDeletedEvent -> toDomain()
is GeneratedPollUpdatedEvent -> toDomain()
Expand Down Expand Up @@ -993,6 +906,106 @@ internal class EventMapping(
)
}

/**
* Transforms the generated [GeneratedNotificationInvitedEvent] to [NotificationInvitedEvent].
*/
private fun GeneratedNotificationInvitedEvent.toDomain(): NotificationInvitedEvent = with(domainMapping) {
val cid = requireNotNull(cid)
val (channelType, channelId) = cid.cidToTypeAndId()
return NotificationInvitedEvent(
type = type,
createdAt = createdAt.date,
rawCreatedAt = createdAt.raw,
cid = cid,
channelType = channelType,
channelId = channelId,
user = requireNotNull(user).toDomain(),
member = member.toDomain(),
)
}

/**
* Transforms the generated [GeneratedNotificationInviteAcceptedEvent] to [NotificationInviteAcceptedEvent].
*/
private fun GeneratedNotificationInviteAcceptedEvent.toDomain(): NotificationInviteAcceptedEvent =
with(domainMapping) {
val cid = requireNotNull(cid)
val (channelType, channelId) = cid.cidToTypeAndId()
return NotificationInviteAcceptedEvent(
type = type,
createdAt = createdAt.date,
rawCreatedAt = createdAt.raw,
cid = cid,
channelType = channelType,
channelId = channelId,
user = requireNotNull(user).toDomain(),
member = member.toDomain(),
channel = channel.toDomain(),
)
}

/**
* Transforms the generated [GeneratedNotificationInviteRejectedEvent] to [NotificationInviteRejectedEvent].
*/
private fun GeneratedNotificationInviteRejectedEvent.toDomain(): NotificationInviteRejectedEvent =
with(domainMapping) {
val cid = requireNotNull(cid)
val (channelType, channelId) = cid.cidToTypeAndId()
return NotificationInviteRejectedEvent(
type = type,
createdAt = createdAt.date,
rawCreatedAt = createdAt.raw,
cid = cid,
channelType = channelType,
channelId = channelId,
user = requireNotNull(user).toDomain(),
member = member.toDomain(),
channel = channel.toDomain(),
)
}

/**
* Transforms the generated [GeneratedNotificationChannelDeletedEvent] to [NotificationChannelDeletedEvent].
*/
private fun GeneratedNotificationChannelDeletedEvent.toDomain(): NotificationChannelDeletedEvent =
with(domainMapping) {
val cid = requireNotNull(cid)
val (channelType, channelId) = cid.cidToTypeAndId()
return NotificationChannelDeletedEvent(
type = type,
createdAt = createdAt.date,
rawCreatedAt = createdAt.raw,
cid = cid,
channelType = channelType,
channelId = channelId,
channel = channel.toDomain(),
totalUnreadCount = totalUnreadCount ?: 0,
unreadChannels = unreadChannels ?: 0,
groupedUnreadChannels = groupedUnreadChannels,
)
}

/**
* Transforms the generated [GeneratedNotificationChannelTruncatedEvent] to [NotificationChannelTruncatedEvent].
*/
private fun GeneratedNotificationChannelTruncatedEvent.toDomain(): NotificationChannelTruncatedEvent =
with(domainMapping) {
val cid = requireNotNull(cid)
val (channelType, channelId) = cid.cidToTypeAndId()
return NotificationChannelTruncatedEvent(
type = type,
createdAt = createdAt.date,
rawCreatedAt = createdAt.raw,
cid = cid,
channelType = channelType,
channelId = channelId,
channel = channel.toDomain(),
totalUnreadCount = totalUnreadCount ?: 0,
unreadChannels = unreadChannels ?: 0,
groupedUnreadChannels = groupedUnreadChannels,
)
}

/**
* Transforms the generated [GeneratedPollClosedEvent] to [PollClosedEvent].
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,74 +202,13 @@ internal data class NotificationAddedToChannelEventDto(
val unread_channels: Int = 0,
) : ChatEventDto()

@JsonClass(generateAdapter = true)
internal data class NotificationChannelDeletedEventDto(
val type: String,
val created_at: ExactDate,
val cid: String,
val channel_type: String,
val channel_id: String,
val channel: DownstreamChannelDto,
val total_unread_count: Int = 0,
val unread_channels: Int = 0,
val grouped_unread_channels: Map<String, Int>? = null,
) : ChatEventDto()

@JsonClass(generateAdapter = true)
internal data class NotificationChannelMutesUpdatedEventDto(
val type: String,
val created_at: ExactDate,
val me: OwnUserResponse,
) : ChatEventDto()

@JsonClass(generateAdapter = true)
internal data class NotificationChannelTruncatedEventDto(
val type: String,
val created_at: ExactDate,
val cid: String,
val channel_type: String,
val channel_id: String,
val channel: DownstreamChannelDto,
val total_unread_count: Int = 0,
val unread_channels: Int = 0,
val grouped_unread_channels: Map<String, Int>? = null,
) : ChatEventDto()

@JsonClass(generateAdapter = true)
internal data class NotificationInviteAcceptedEventDto(
val type: String,
val created_at: ExactDate,
val cid: String,
val channel_type: String,
val channel_id: String,
val user: DownstreamUserDto,
val member: ChannelMemberResponse,
val channel: DownstreamChannelDto,
) : ChatEventDto()

@JsonClass(generateAdapter = true)
internal data class NotificationInviteRejectedEventDto(
val type: String,
val created_at: ExactDate,
val cid: String,
val channel_type: String,
val channel_id: String,
val user: DownstreamUserDto,
val member: ChannelMemberResponse,
val channel: DownstreamChannelDto,
) : ChatEventDto()

@JsonClass(generateAdapter = true)
internal data class NotificationInvitedEventDto(
val type: String,
val created_at: ExactDate,
val cid: String,
val channel_type: String,
val channel_id: String,
val user: DownstreamUserDto,
val member: ChannelMemberResponse,
) : ChatEventDto()

@JsonClass(generateAdapter = true)
internal data class NotificationMarkReadEventDto(
val type: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ import io.getstream.chat.android.client.api2.model.dto.MessageReadEventDto
import io.getstream.chat.android.client.api2.model.dto.MessageUpdatedEventDto
import io.getstream.chat.android.client.api2.model.dto.NewMessageEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationAddedToChannelEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationChannelDeletedEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationChannelMutesUpdatedEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationChannelTruncatedEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationInviteAcceptedEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationInviteRejectedEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationInvitedEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationMarkReadEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationMarkUnreadEventDto
import io.getstream.chat.android.client.api2.model.dto.NotificationMutesUpdatedEventDto
Expand All @@ -69,6 +64,11 @@ import io.getstream.chat.android.models.EventType
import io.getstream.chat.android.network.models.MemberAddedEvent
import io.getstream.chat.android.network.models.MemberRemovedEvent
import io.getstream.chat.android.network.models.MemberUpdatedEvent
import io.getstream.chat.android.network.models.NotificationChannelDeletedEvent
import io.getstream.chat.android.network.models.NotificationChannelTruncatedEvent
import io.getstream.chat.android.network.models.NotificationInviteAcceptedEvent
import io.getstream.chat.android.network.models.NotificationInviteRejectedEvent
import io.getstream.chat.android.network.models.NotificationInvitedEvent
import io.getstream.chat.android.network.models.NotificationNewMessageEvent
import io.getstream.chat.android.network.models.PollClosedEvent
import io.getstream.chat.android.network.models.PollDeletedEvent
Expand Down Expand Up @@ -151,17 +151,24 @@ internal class EventDtoAdapter(
private val threadUpdatedEventAdapter = generatedEventAdapter<ThreadUpdatedEvent> {
mapOf("cid" to cid, "channel_type" to channelType, "channel_id" to channelId, "thread" to thread)
}
private val notificationInvitedEventAdapter = moshi.adapter(NotificationInvitedEventDto::class.java)
private val notificationInviteAcceptedEventAdapter = moshi.adapter(NotificationInviteAcceptedEventDto::class.java)
private val notificationInviteRejectedEventAdapter = moshi.adapter(NotificationInviteRejectedEventDto::class.java)
private val notificationInvitedEventAdapter = generatedEventAdapter<NotificationInvitedEvent> {
mapOf("cid" to cid, "user" to user)
}
private val notificationInviteAcceptedEventAdapter = generatedEventAdapter<NotificationInviteAcceptedEvent> {
mapOf("cid" to cid, "user" to user)
}
private val notificationInviteRejectedEventAdapter = generatedEventAdapter<NotificationInviteRejectedEvent> {
mapOf("cid" to cid, "user" to user)
}
private val notificationRemovedFromChannelEventAdapter =
moshi.adapter(NotificationRemovedFromChannelEventDto::class.java)
private val notificationMutesUpdatedEventAdapter = moshi.adapter(NotificationMutesUpdatedEventDto::class.java)
private val notificationChannelMutesUpdatedEventAdapter =
moshi.adapter(NotificationChannelMutesUpdatedEventDto::class.java)
private val notificationChannelDeletedEventAdapter = moshi.adapter(NotificationChannelDeletedEventDto::class.java)
private val notificationChannelDeletedEventAdapter =
generatedEventAdapter<NotificationChannelDeletedEvent> { mapOf("cid" to cid) }
private val notificationChannelTruncatedEventAdapter =
moshi.adapter(NotificationChannelTruncatedEventDto::class.java)
generatedEventAdapter<NotificationChannelTruncatedEvent> { mapOf("cid" to cid) }
private val userPresenceChangedEventAdapter = generatedEventAdapter<UserPresenceChangedEvent> { emptyMap() }
private val userUpdatedEventAdapter = moshi.adapter(UserUpdatedEventDto::class.java)
private val userDeletedEventAdapter = generatedEventAdapter<UserDeletedEvent> { emptyMap() }
Expand Down
Loading
Loading