Replace some more longs with ints.

This commit is contained in:
akwizgran
2023-02-20 13:53:40 +00:00
parent 36db5b48ef
commit 1b808584b6
2 changed files with 7 additions and 6 deletions

View File

@@ -76,7 +76,7 @@ class AvatarValidator implements MessageValidator {
// 0.0: Message Type, Version, Content-Type
checkSize(body, 3);
// Message Type
long messageType = body.getInt(0);
int messageType = body.getInt(0);
if (messageType != MSG_TYPE_UPDATE) throw new FormatException();
// Version
long version = body.getLong(1);

View File

@@ -182,7 +182,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
try {
BdfDictionary metaDict = metadataParser.parse(meta);
// Message type is null for version 0.0 private messages
Long messageType = metaDict.getOptionalLong(MSG_KEY_MSG_TYPE);
Integer messageType = metaDict.getOptionalInt(MSG_KEY_MSG_TYPE);
if (messageType == null) {
incomingPrivateMessage(txn, m, metaDict, true, emptyList());
} else if (messageType == PRIVATE_MESSAGE) {
@@ -419,7 +419,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
if (meta == null) continue;
try {
// Message type is null for version 0.0 private messages
Long messageType = meta.getOptionalLong(MSG_KEY_MSG_TYPE);
Integer messageType = meta.getOptionalInt(MSG_KEY_MSG_TYPE);
if (messageType != null && messageType != PRIVATE_MESSAGE)
continue;
long timestamp = meta.getLong(MSG_KEY_TIMESTAMP);
@@ -453,7 +453,8 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
Map<MessageId, BdfDictionary> messages =
clientHelper.getMessageMetadataAsDictionary(txn, g);
for (Entry<MessageId, BdfDictionary> entry : messages.entrySet()) {
Long type = entry.getValue().getOptionalLong(MSG_KEY_MSG_TYPE);
Integer type =
entry.getValue().getOptionalInt(MSG_KEY_MSG_TYPE);
if (type == null || type == PRIVATE_MESSAGE)
result.add(entry.getKey());
}
@@ -527,7 +528,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
try {
BdfDictionary meta =
clientHelper.getMessageMetadataAsDictionary(txn, m);
Long messageType = meta.getOptionalLong(MSG_KEY_MSG_TYPE);
Integer messageType = meta.getOptionalInt(MSG_KEY_MSG_TYPE);
if (messageType != null && messageType == PRIVATE_MESSAGE) {
for (AttachmentHeader h : parseAttachmentHeaders(g, meta)) {
try {
@@ -554,7 +555,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
int unreadCount = 0;
for (Entry<MessageId, BdfDictionary> entry : metadata.entrySet()) {
BdfDictionary meta = entry.getValue();
Long messageType = meta.getOptionalLong(MSG_KEY_MSG_TYPE);
Integer messageType = meta.getOptionalInt(MSG_KEY_MSG_TYPE);
if (messageType == null || messageType == PRIVATE_MESSAGE) {
msgCount++;
if (!meta.getBoolean(MSG_KEY_READ)) unreadCount++;