1
0
mirror of https://github.com/areteruhiro/LIME-beta-hiro.git synced 2025-02-05 21:11:39 +09:00

Update ReadChecker.java

This commit is contained in:
areteruhiro 2025-01-23 20:47:21 +09:00 committed by GitHub
parent be24fe1a53
commit 9d79eaebf0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -324,19 +324,48 @@ public class ReadChecker implements IHook {
return;
}
// group_id null のレコードを探しchat_history から chat_id を取得して更新する
Cursor nullGroupIdCursor = limeDatabase.rawQuery("SELECT server_id FROM read_message WHERE group_id = 'null'", null);
while (nullGroupIdCursor.moveToNext()) {
String serverId = nullGroupIdCursor.getString(0);
String chatId = queryDatabase(db3, "SELECT chat_id FROM chat_history WHERE server_id=?", serverId);
if (chatId != null && !"null".equals(chatId)) {
limeDatabase.execSQL("UPDATE read_message SET group_id=? WHERE server_id=?", new String[]{chatId, serverId});
}
}
nullGroupIdCursor.close();
// group_id null のレコードを探しchat_history から chat_id を取得して更新する
Cursor nullGroupIdCursor = limeDatabase.rawQuery("SELECT server_id FROM read_message WHERE group_id = 'null'", null);
while (nullGroupIdCursor.moveToNext()) {
String serverId = nullGroupIdCursor.getString(0);
String chatId = queryDatabase(db3, "SELECT chat_id FROM chat_history WHERE server_id=?", serverId);
if (chatId != null && !"null".equals(chatId)) {
limeDatabase.execSQL("UPDATE read_message SET group_id=? WHERE server_id=?", new String[]{chatId, serverId});
}
}
nullGroupIdCursor.close();
// SQLクエリの初期化
String query;
// SQLクエリの初期化
String query;
// group_id server_id を指定してread_message テーブルからレコードを取得
String selectQuery = "SELECT server_id, Sent_User, Send_User, group_name, content, created_time FROM read_message WHERE group_id = ? AND server_id != ?";
Cursor cursor = null;
try {
cursor = limeDatabase.rawQuery(selectQuery, new String[]{groupId, serverId});
// 検索結果をループ処理
while (cursor.moveToNext()) {
String otherServerId = cursor.getString(0);
String otherSentUser = cursor.getString(1);
String otherSendUser = cursor.getString(2);
String otherGroupName = cursor.getString(3);
String otherContent = cursor.getString(4);
String othertimeFormatted = cursor.getString(5);
// Sent_User が存在しない場合のみ処理
if (!otherSentUser.equals(SentUser)) {
// user_name のみ変更して新しいレコードを挿入
insertRecord(otherSendUser, groupId, otherServerId, SentUser, otherGroupName, otherContent, user_name, othertimeFormatted);
XposedBridge.log("Copied record inserted: server_id=" + otherServerId + ", Sent_User=" + SentUser);
}
}
} finally {
if (cursor != null) {
cursor.close();
}
}
if (limeOptions.MySendMessage.checked) {
// Send_User (null) のメッセージのみを取得するクエリ
query = "SELECT server_id, content, created_time FROM read_message WHERE group_id=? AND Send_User = 'null' ORDER BY created_time ASC";