mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 08:46:15 +00:00
Committing current state.
This commit is contained in:
parent
f250f40e5e
commit
ae95481e54
@ -47,6 +47,7 @@ import java.text.SimpleDateFormat;
|
||||
|
||||
import de.fabianonline.telegram_backup.mediafilemanager.AbstractMediaFileManager;
|
||||
import de.fabianonline.telegram_backup.mediafilemanager.FileManagerFactory;
|
||||
import de.fabianonline.telegram_backup.models.Message;
|
||||
|
||||
public class Database {
|
||||
private Connection conn;
|
||||
@ -396,12 +397,12 @@ public class Database {
|
||||
}
|
||||
}
|
||||
|
||||
public LinkedList<TLMessage> getMessagesWithMedia() {
|
||||
public LinkedList<Message> getMessagesWithMedia() {
|
||||
try {
|
||||
LinkedList<TLMessage> list = new LinkedList<TLMessage>();
|
||||
ResultSet rs = stmt.executeQuery("SELECT data FROM messages WHERE has_media=1");
|
||||
LinkedList<Message> list = new LinkedList<Message>();
|
||||
ResultSet rs = stmt.executeQuery("SELECT json FROM messages WHERE has_media=1");
|
||||
while (rs.next()) {
|
||||
list.add(bytesToTLMessage(rs.getBytes(1)));
|
||||
list.add(new Message(rs.getString(1)));
|
||||
}
|
||||
rs.close();
|
||||
return list;
|
||||
|
@ -137,7 +137,7 @@ class TelegramUpdateHandler implements UpdateCallback {
|
||||
private void processUpdate(TLAbsUpdate update, TelegramClient client) {
|
||||
if (update instanceof TLUpdateNewMessage) {
|
||||
TLAbsMessage abs_msg = ((TLUpdateNewMessage)update).getMessage();
|
||||
Message msg = new Message(abs_msg);
|
||||
Message msg = Message.fromObject(abs_msg);
|
||||
msg.save();
|
||||
System.out.print('.');
|
||||
AbstractMediaFileManager fm = FileManagerFactory.getFileManager(msg);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.fabianonline.telegram_backup.models;
|
||||
|
||||
import de.fabianonline.telegram_backup.Database;
|
||||
import de.fabianonline.telegram_backup.Utils;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
@ -15,6 +16,10 @@ public class Message {
|
||||
this.json = new JsonParser().parse(json).getAsJsonObject();
|
||||
}
|
||||
|
||||
public static Message fromObject(TLAbsMessage msg) {
|
||||
return new Message(Utils.getGson().fromObject(msg));
|
||||
}
|
||||
|
||||
public static Message get(int id) {
|
||||
String json = Database.getInstance().queryString("SELECT json FROM " + tableName + " WHERE id=" + id);
|
||||
return new Message(json);
|
||||
|
Loading…
Reference in New Issue
Block a user