用户消息表中的target优化
This commit is contained in:
@@ -915,7 +915,7 @@ public class DatabaseStore {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void persistUserMessage(final String userId, final long messageId, final long messageSeq, int type, String target, int line, boolean directing, final int messageContentType) {
|
void persistUserMessage(final String userId, final String sender, final long messageId, final long messageSeq, int type, String target, int line, boolean directing, final int messageContentType) {
|
||||||
mScheduler.execute(()->{
|
mScheduler.execute(()->{
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
@@ -930,7 +930,7 @@ public class DatabaseStore {
|
|||||||
statement.setString(index++, userId);
|
statement.setString(index++, userId);
|
||||||
statement.setLong(index++, messageSeq);
|
statement.setLong(index++, messageSeq);
|
||||||
statement.setInt(index++, type);
|
statement.setInt(index++, type);
|
||||||
statement.setString(index++, target);
|
statement.setString(index++, getPrivateChatUserMessageTarget(type, target, sender));
|
||||||
statement.setInt(index++, line);
|
statement.setInt(index++, line);
|
||||||
statement.setInt(index++, directing ? 1 :0);
|
statement.setInt(index++, directing ? 1 :0);
|
||||||
statement.setInt(index++, messageContentType);
|
statement.setInt(index++, messageContentType);
|
||||||
@@ -946,6 +946,14 @@ public class DatabaseStore {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getPrivateChatUserMessageTarget(int conversationType, String target, String userId) {
|
||||||
|
if(conversationType == ProtoConstants.ConversationType.ConversationType_Private) {
|
||||||
|
return target.compareTo(userId) > 0 ? (userId + "|" + target) : (target + "|" + userId);
|
||||||
|
} else {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void clearUserMessage(final String userId) {
|
void clearUserMessage(final String userId) {
|
||||||
mScheduler.execute(()->{
|
mScheduler.execute(()->{
|
||||||
String tableName = getUserMessageTable(userId);
|
String tableName = getUserMessageTable(userId);
|
||||||
|
|||||||
@@ -1012,7 +1012,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
mWriteLock.unlock();
|
mWriteLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
databaseStore.persistUserMessage(user, messageId, messageSeq, conversationType, target, line, directing, messageContentType);
|
databaseStore.persistUserMessage(user, sender, messageId, messageSeq, conversationType, target, line, directing, messageContentType);
|
||||||
return messageSeq;
|
return messageSeq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user