mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 01:45:52 +03:00
Rename "sender" to "senderId" for code clarity
This commit is contained in:
parent
625500212d
commit
8c0a1ed37d
23 changed files with 45 additions and 46 deletions
|
@ -59,7 +59,7 @@ object RoomDataHelper {
|
|||
eventId = Random.nextLong().toString(),
|
||||
content = content,
|
||||
prevContent = prevContent,
|
||||
sender = sender,
|
||||
senderId = sender,
|
||||
stateKey = stateKey
|
||||
)
|
||||
}
|
||||
|
|
|
@ -71,13 +71,11 @@ data class Event(
|
|||
@Json(name = "content") val content: Content? = null,
|
||||
@Json(name = "prev_content") val prevContent: Content? = null,
|
||||
@Json(name = "origin_server_ts") val originServerTs: Long? = null,
|
||||
// MatrixId of the sender (TODO rename)
|
||||
@Json(name = "sender") val sender: String? = null,
|
||||
@Json(name = "sender") val senderId: String? = null,
|
||||
@Json(name = "state_key") val stateKey: String? = null,
|
||||
@Json(name = "room_id") val roomId: String? = null,
|
||||
@Json(name = "unsigned") val unsignedData: UnsignedData? = null,
|
||||
@Json(name = "redacts") val redacts: String? = null
|
||||
|
||||
) {
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,12 +56,12 @@ data class TimelineEvent(
|
|||
|
||||
fun getDisambiguatedDisplayName(): String {
|
||||
return if (isUniqueDisplayName) {
|
||||
senderName ?: root.sender
|
||||
senderName ?: root.senderId
|
||||
} else {
|
||||
senderName?.let {
|
||||
it + " (" + root.sender + ")"
|
||||
it + " (" + root.senderId + ")"
|
||||
}
|
||||
?: root.sender
|
||||
?: root.senderId
|
||||
}
|
||||
?: ""
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ open class IncomingRoomKeyRequest {
|
|||
* @param event the event
|
||||
*/
|
||||
constructor(event: Event) {
|
||||
userId = event.sender
|
||||
userId = event.senderId
|
||||
val roomKeyShareRequest = event.getClearContent().toModel<RoomKeyShareRequest>()!!
|
||||
deviceId = roomKeyShareRequest.requestingDeviceId
|
||||
requestId = roomKeyShareRequest.requestId
|
||||
|
|
|
@ -131,7 +131,7 @@ internal class MXMegolmDecryption(private val credentials: Credentials,
|
|||
* @param event the event
|
||||
*/
|
||||
private fun requestKeysForEvent(event: Event) {
|
||||
val sender = event.sender!!
|
||||
val sender = event.senderId!!
|
||||
val encryptedEventContent = event.content.toModel<EncryptedEventContent>()!!
|
||||
|
||||
val recipients = ArrayList<Map<String, String>>()
|
||||
|
|
|
@ -121,9 +121,9 @@ internal class MXOlmDecryption(
|
|||
MXCryptoError.UNABLE_TO_DECRYPT, String.format(MXCryptoError.ERROR_MISSING_PROPERTY_REASON, "sender")))
|
||||
}
|
||||
|
||||
if (!TextUtils.equals(olmPayloadContent.sender, event.sender)) {
|
||||
if (!TextUtils.equals(olmPayloadContent.sender, event.senderId)) {
|
||||
Timber.e("Event " + event.eventId + ": original sender " + olmPayloadContent.sender
|
||||
+ " does not match reported sender " + event.sender)
|
||||
+ " does not match reported sender " + event.senderId)
|
||||
throw MXDecryptionException(MXCryptoError(MXCryptoError.FORWARDED_MESSAGE_ERROR_CODE,
|
||||
MXCryptoError.UNABLE_TO_DECRYPT, String.format(MXCryptoError.FORWARDED_MESSAGE_REASON, olmPayloadContent.sender)))
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ internal class DefaultSasVerificationService(private val credentials: Credential
|
|||
private suspend fun onStartRequestReceived(event: Event) {
|
||||
val startReq = event.getClearContent().toModel<KeyVerificationStart>()!!
|
||||
|
||||
val otherUserId = event.sender
|
||||
val otherUserId = event.senderId
|
||||
if (!startReq.isValid()) {
|
||||
Timber.e("## received invalid verification request")
|
||||
if (startReq.transactionID != null) {
|
||||
|
@ -236,7 +236,7 @@ internal class DefaultSasVerificationService(private val credentials: Credential
|
|||
Timber.e("## Received invalid accept request")
|
||||
return
|
||||
}
|
||||
val otherUserId = event.sender!!
|
||||
val otherUserId = event.senderId!!
|
||||
|
||||
Timber.v("## SAS onCancelReceived otherUser:$otherUserId reason:${cancelReq.reason}")
|
||||
val existing = getExistingTransaction(otherUserId, cancelReq.transactionID!!)
|
||||
|
@ -258,7 +258,7 @@ internal class DefaultSasVerificationService(private val credentials: Credential
|
|||
Timber.e("## Received invalid accept request")
|
||||
return
|
||||
}
|
||||
val otherUserId = event.sender!!
|
||||
val otherUserId = event.senderId!!
|
||||
val existing = getExistingTransaction(otherUserId, acceptReq.transactionID!!)
|
||||
if (existing == null) {
|
||||
Timber.e("## Received invalid accept request")
|
||||
|
@ -282,7 +282,7 @@ internal class DefaultSasVerificationService(private val credentials: Credential
|
|||
Timber.e("## Received invalid key request")
|
||||
return
|
||||
}
|
||||
val otherUserId = event.sender!!
|
||||
val otherUserId = event.senderId!!
|
||||
val existing = getExistingTransaction(otherUserId, keyReq.transactionID!!)
|
||||
if (existing == null) {
|
||||
Timber.e("## Received invalid accept request")
|
||||
|
@ -303,7 +303,7 @@ internal class DefaultSasVerificationService(private val credentials: Credential
|
|||
Timber.e("## Received invalid key request")
|
||||
return
|
||||
}
|
||||
val otherUserId = event.sender!!
|
||||
val otherUserId = event.senderId!!
|
||||
val existing = getExistingTransaction(otherUserId, macReq.transactionID!!)
|
||||
if (existing == null) {
|
||||
Timber.e("## Received invalid accept request")
|
||||
|
|
|
@ -37,7 +37,7 @@ internal object EventMapper {
|
|||
eventEntity.prevContent = ContentMapper.map(resolvedPrevContent)
|
||||
eventEntity.stateKey = event.stateKey
|
||||
eventEntity.type = event.getClearType()
|
||||
eventEntity.sender = event.sender
|
||||
eventEntity.sender = event.senderId
|
||||
eventEntity.originServerTs = event.originServerTs
|
||||
eventEntity.redacts = event.redacts
|
||||
eventEntity.age = event.unsignedData?.age ?: event.originServerTs
|
||||
|
@ -63,7 +63,7 @@ internal object EventMapper {
|
|||
content = ContentMapper.map(eventEntity.content),
|
||||
prevContent = ContentMapper.map(eventEntity.prevContent),
|
||||
originServerTs = eventEntity.originServerTs,
|
||||
sender = eventEntity.sender,
|
||||
senderId = eventEntity.sender,
|
||||
stateKey = eventEntity.stateKey,
|
||||
roomId = eventEntity.roomId,
|
||||
unsignedData = ud,
|
||||
|
|
|
@ -227,7 +227,7 @@ internal class DefaultEventRelationsAggregationTask(private val monarchy: Monarc
|
|||
sum.count = 1
|
||||
sum.sourceEvents.add(reactionEventId)
|
||||
}
|
||||
sum.addedByMe = sum.addedByMe || (userId == event.sender)
|
||||
sum.addedByMe = sum.addedByMe || (userId == event.senderId)
|
||||
eventSummary.reactionsSummary.add(sum)
|
||||
} else {
|
||||
//is this a known event (is possible? pagination?)
|
||||
|
@ -249,7 +249,7 @@ internal class DefaultEventRelationsAggregationTask(private val monarchy: Monarc
|
|||
sum.sourceEvents.add(reactionEventId)
|
||||
}
|
||||
|
||||
sum.addedByMe = sum.addedByMe || (userId == event.sender)
|
||||
sum.addedByMe = sum.addedByMe || (userId == event.senderId)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import im.vector.matrix.android.api.session.events.model.EventType
|
|||
import im.vector.matrix.android.api.session.room.model.message.MessageTextContent
|
||||
import im.vector.matrix.android.internal.di.MoshiProvider
|
||||
|
||||
// TODO Remove
|
||||
internal class EventFactory(private val credentials: Credentials) {
|
||||
|
||||
private val moshi = MoshiProvider.providesMoshi()
|
||||
|
@ -33,7 +34,7 @@ internal class EventFactory(private val credentials: Credentials) {
|
|||
return Event(
|
||||
roomId = roomId,
|
||||
originServerTs = dummyOriginServerTs(),
|
||||
sender = credentials.userId,
|
||||
senderId = credentials.userId,
|
||||
eventId = dummyEventId(roomId),
|
||||
type = EventType.MESSAGE,
|
||||
content = toContent(content)
|
||||
|
|
|
@ -130,7 +130,7 @@ internal class LocalEchoEventFactory(private val credentials: Credentials, priva
|
|||
return Event(
|
||||
roomId = roomId,
|
||||
originServerTs = dummyOriginServerTs(),
|
||||
sender = credentials.userId,
|
||||
senderId = credentials.userId,
|
||||
eventId = localId,
|
||||
type = EventType.REACTION,
|
||||
content = content.toContent(),
|
||||
|
@ -221,7 +221,7 @@ internal class LocalEchoEventFactory(private val credentials: Credentials, priva
|
|||
return Event(
|
||||
roomId = roomId,
|
||||
originServerTs = dummyOriginServerTs(),
|
||||
sender = credentials.userId,
|
||||
senderId = credentials.userId,
|
||||
eventId = localID,
|
||||
type = EventType.MESSAGE,
|
||||
content = content.toContent(),
|
||||
|
@ -241,7 +241,7 @@ internal class LocalEchoEventFactory(private val credentials: Credentials, priva
|
|||
//Fallbacks and event representation
|
||||
//TODO Add error/warning logs when any of this is null
|
||||
val permalink = PermalinkFactory.createPermalink(eventReplied) ?: return null
|
||||
val userId = eventReplied.sender ?: return null
|
||||
val userId = eventReplied.senderId ?: return null
|
||||
val userLink = PermalinkFactory.createPermalink(userId) ?: return null
|
||||
// <mx-reply>
|
||||
// <blockquote>
|
||||
|
@ -330,7 +330,7 @@ internal class LocalEchoEventFactory(private val credentials: Credentials, priva
|
|||
return Event(
|
||||
roomId = roomId,
|
||||
originServerTs = dummyOriginServerTs(),
|
||||
sender = credentials.userId,
|
||||
senderId = credentials.userId,
|
||||
eventId = localID,
|
||||
type = EventType.REDACTION,
|
||||
redacts = eventId,
|
||||
|
|
|
@ -257,7 +257,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
|||
|
||||
try {
|
||||
return Event(eventId = data["event_id"],
|
||||
sender = data["sender"],
|
||||
senderId = data["sender"],
|
||||
roomId = data["room_id"],
|
||||
type = data.getValue("type"),
|
||||
// TODO content = data.getValue("content"),
|
||||
|
|
|
@ -223,7 +223,7 @@ class RoomDetailFragment :
|
|||
//switch to expanded bar
|
||||
composerLayout.composerRelatedMessageTitle.apply {
|
||||
text = event.getDisambiguatedDisplayName()
|
||||
setTextColor(ContextCompat.getColor(requireContext(), getColorFromUserId(event.root.sender)))
|
||||
setTextColor(ContextCompat.getColor(requireContext(), getColorFromUserId(event.root.senderId)))
|
||||
}
|
||||
|
||||
//TODO this is used at several places, find way to refactor?
|
||||
|
@ -255,7 +255,7 @@ class RoomDetailFragment :
|
|||
composerLayout.composerRelatedMessageActionIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_reply))
|
||||
}
|
||||
|
||||
AvatarRenderer.render(event.senderAvatar, event.root.sender
|
||||
AvatarRenderer.render(event.senderAvatar, event.root.senderId
|
||||
?: "", event.senderName, composerLayout.composerRelatedMessageAvatar)
|
||||
|
||||
composerLayout.composerEditText.setSelection(composerLayout.composerEditText.text.length)
|
||||
|
|
|
@ -429,7 +429,7 @@ class RoomDetailViewModel(initialState: RoomDetailViewState,
|
|||
private fun observeInvitationState() {
|
||||
asyncSubscribe(RoomDetailViewState::asyncRoomSummary) { summary ->
|
||||
if (summary.membership == Membership.INVITE) {
|
||||
summary.lastMessage?.sender?.let { senderId ->
|
||||
summary.lastMessage?.senderId?.let { senderId ->
|
||||
session.getUser(senderId)
|
||||
}?.also {
|
||||
setState { copy(asyncInviter = Success(it)) }
|
||||
|
|
|
@ -238,7 +238,7 @@ class TimelineEventController(private val dateFormatter: TimelineDateFormatter,
|
|||
val senderAvatar = mergedEvent.senderAvatar()
|
||||
val senderName = mergedEvent.senderName()
|
||||
MergedHeaderItem.Data(
|
||||
userId = mergedEvent.root.sender ?: "",
|
||||
userId = mergedEvent.root.senderId ?: "",
|
||||
avatarUrl = senderAvatar,
|
||||
memberName = senderName ?: "",
|
||||
eventId = mergedEvent.localId
|
||||
|
|
|
@ -90,7 +90,7 @@ class MessageActionsViewModel(initialState: MessageActionState) : VectorViewMode
|
|||
}
|
||||
}
|
||||
MessageActionState(
|
||||
userId = event.root.sender ?: "",
|
||||
userId = event.root.senderId ?: "",
|
||||
senderName = parcel.informationData.memberName?.toString() ?: "",
|
||||
messageBody = body,
|
||||
ts = dateFormat.format(Date(originTs ?: 0)),
|
||||
|
|
|
@ -131,7 +131,7 @@ class MessageMenuViewModel(initialState: MessageMenuState) : VectorViewModel<Mes
|
|||
}
|
||||
this.add(SimpleAction(ACTION_COPY_PERMALINK, R.string.permalink, R.drawable.ic_permalink, parcel.eventId))
|
||||
|
||||
if (currentSession.sessionParams.credentials.userId != event.root.sender && event.root.getClearType() == EventType.MESSAGE) {
|
||||
if (currentSession.sessionParams.credentials.userId != event.root.senderId && event.root.getClearType() == EventType.MESSAGE) {
|
||||
//not sent by me
|
||||
this.add(SimpleAction(ACTION_FLAG, R.string.report_content, R.drawable.ic_flag, parcel.eventId))
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ class MessageMenuViewModel(initialState: MessageMenuState) : VectorViewModel<Mes
|
|||
//Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment
|
||||
if (event.root.getClearType() != EventType.MESSAGE) return false
|
||||
//TODO if user is admin or moderator
|
||||
return event.root.sender == myUserId
|
||||
return event.root.senderId == myUserId
|
||||
}
|
||||
|
||||
private fun canViewReactions(event: TimelineEvent): Boolean {
|
||||
|
@ -194,7 +194,7 @@ class MessageMenuViewModel(initialState: MessageMenuState) : VectorViewModel<Mes
|
|||
if (event.root.getClearType() != EventType.MESSAGE) return false
|
||||
//TODO if user is admin or moderator
|
||||
val messageContent = event.root.content.toModel<MessageContent>()
|
||||
return event.root.sender == myUserId && (
|
||||
return event.root.senderId == myUserId && (
|
||||
messageContent?.type == MessageType.MSGTYPE_TEXT
|
||||
|| messageContent?.type == MessageType.MSGTYPE_EMOTE
|
||||
)
|
||||
|
|
|
@ -49,7 +49,7 @@ class ViewReactionViewModel(private val session: Session,
|
|||
|
||||
sum.sourceEvents.mapNotNull { room.getTimeLineEvent(it) }.forEach {
|
||||
val localDate = it.root.localDateTime()
|
||||
results.add(ReactionInfo(it.root.eventId!!, sum.key, it.root.sender
|
||||
results.add(ReactionInfo(it.root.eventId!!, sum.key, it.root.senderId
|
||||
?: "", it.getDisambiguatedDisplayName(), timelineDateFormatter.formatMessageHour(localDate)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class EncryptionItemFactory(private val stringProvider: StringProvider) {
|
|||
val text = buildNoticeText(event.root, event.senderName) ?: return null
|
||||
val informationData = MessageInformationData(
|
||||
eventId = event.root.eventId ?: "?",
|
||||
senderId = event.root.sender ?: "",
|
||||
senderId = event.root.senderId ?: "",
|
||||
sendState = event.sendState,
|
||||
avatarUrl = event.senderAvatar(),
|
||||
memberName = event.senderName(),
|
||||
|
|
|
@ -32,7 +32,7 @@ class NoticeItemFactory(private val eventFormatter: NoticeEventFormatter) {
|
|||
val formattedText = eventFormatter.format(event) ?: return null
|
||||
val informationData = MessageInformationData(
|
||||
eventId = event.root.eventId ?: "?",
|
||||
senderId = event.root.sender ?: "",
|
||||
senderId = event.root.senderId ?: "",
|
||||
sendState = event.sendState,
|
||||
avatarUrl = event.senderAvatar(),
|
||||
memberName = event.senderName(),
|
||||
|
|
|
@ -65,7 +65,7 @@ class TimelineItemFactory(private val messageItemFactory: MessageItemFactory,
|
|||
if (TimelineDisplayableEvents.DEBUG_HIDDEN_EVENT) {
|
||||
val informationData = MessageInformationData(eventId = event.root.eventId
|
||||
?: "?",
|
||||
senderId = event.root.sender ?: "",
|
||||
senderId = event.root.senderId ?: "",
|
||||
sendState = event.sendState,
|
||||
time = "",
|
||||
avatarUrl = null,
|
||||
|
|
|
@ -111,12 +111,12 @@ class NoticeEventFormatter(private val stringProvider: StringProvider) {
|
|||
if (!TextUtils.equals(eventContent?.displayName, prevEventContent?.displayName)) {
|
||||
val displayNameText = when {
|
||||
prevEventContent?.displayName.isNullOrEmpty() ->
|
||||
stringProvider.getString(R.string.notice_display_name_set, event.sender, eventContent?.displayName)
|
||||
stringProvider.getString(R.string.notice_display_name_set, event.senderId, eventContent?.displayName)
|
||||
eventContent?.displayName.isNullOrEmpty() ->
|
||||
stringProvider.getString(R.string.notice_display_name_removed, event.sender, prevEventContent?.displayName)
|
||||
stringProvider.getString(R.string.notice_display_name_removed, event.senderId, prevEventContent?.displayName)
|
||||
else ->
|
||||
stringProvider.getString(R.string.notice_display_name_changed_from,
|
||||
event.sender, prevEventContent?.displayName, eventContent?.displayName)
|
||||
event.senderId, prevEventContent?.displayName, eventContent?.displayName)
|
||||
}
|
||||
displayText.append(displayNameText)
|
||||
}
|
||||
|
@ -134,8 +134,8 @@ class NoticeEventFormatter(private val stringProvider: StringProvider) {
|
|||
}
|
||||
|
||||
private fun buildMembershipNotice(event: Event, senderName: String?, eventContent: RoomMember?, prevEventContent: RoomMember?): String? {
|
||||
val senderDisplayName = senderName ?: event.sender
|
||||
val targetDisplayName = eventContent?.displayName ?: event.sender
|
||||
val senderDisplayName = senderName ?: event.senderId
|
||||
val targetDisplayName = eventContent?.displayName ?: event.senderId
|
||||
return when {
|
||||
Membership.INVITE == eventContent?.membership -> {
|
||||
// TODO get userId
|
||||
|
@ -156,7 +156,7 @@ class NoticeEventFormatter(private val stringProvider: StringProvider) {
|
|||
stringProvider.getString(R.string.notice_room_join, senderDisplayName)
|
||||
Membership.LEAVE == eventContent?.membership ->
|
||||
// 2 cases here: this member may have left voluntarily or they may have been "left" by someone else ie. kicked
|
||||
return if (TextUtils.equals(event.sender, event.stateKey)) {
|
||||
return if (TextUtils.equals(event.senderId, event.stateKey)) {
|
||||
if (prevEventContent?.membership == Membership.INVITE) {
|
||||
stringProvider.getString(R.string.notice_room_reject, senderDisplayName)
|
||||
} else {
|
||||
|
|
|
@ -53,7 +53,7 @@ class MessageInformationDataFactory(private val timelineDateFormatter: TimelineD
|
|||
val avatarUrl = event.senderAvatar
|
||||
val memberName = event.getDisambiguatedDisplayName()
|
||||
val formattedMemberName = span(memberName) {
|
||||
textColor = colorProvider.getColor(getColorFromUserId(event.root.sender
|
||||
textColor = colorProvider.getColor(getColorFromUserId(event.root.senderId
|
||||
?: ""))
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class MessageInformationDataFactory(private val timelineDateFormatter: TimelineD
|
|||
|
||||
return MessageInformationData(
|
||||
eventId = eventId,
|
||||
senderId = event.root.sender ?: "",
|
||||
senderId = event.root.senderId ?: "",
|
||||
sendState = event.sendState,
|
||||
time = time,
|
||||
avatarUrl = avatarUrl,
|
||||
|
|
Loading…
Reference in a new issue