aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/database.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-31 01:17:01 +0200
committerfiaxh <git@mx.ax.lt>2017-03-31 16:39:28 +0200
commit22adbd38dca0868f0e10754314a3859bba0a7d87 (patch)
tree44ecf9cf8af6aef78030dade95aecb1de2b99873 /libdino/src/service/database.vala
parent7d2f995a097086be01426cc79c9c801dabaf9e3b (diff)
downloaddino-22adbd38dca0868f0e10754314a3859bba0a7d87.tar.gz
dino-22adbd38dca0868f0e10754314a3859bba0a7d87.zip
Handle MUC private messages
Diffstat (limited to 'libdino/src/service/database.vala')
-rw-r--r--libdino/src/service/database.vala11
1 files changed, 9 insertions, 2 deletions
diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala
index 4115bcfa..ad12cbac 100644
--- a/libdino/src/service/database.vala
+++ b/libdino/src/service/database.vala
@@ -79,6 +79,7 @@ public class Database : Qlite.Database {
public Column<int> id = new Column.Integer("id") { primary_key = true, auto_increment = true };
public Column<int> account_id = new Column.Integer("account_id") { not_null = true };
public Column<int> jid_id = new Column.Integer("jid_id") { not_null = true };
+ public Column<string> resource = new Column.Text("resource");
public Column<bool> active = new Column.BoolInt("active");
public Column<long> last_active = new Column.Long("last_active");
public Column<int> type_ = new Column.Integer("type");
@@ -87,7 +88,7 @@ public class Database : Qlite.Database {
internal ConversationTable(Database db) {
base(db, "conversation");
- init({id, account_id, jid_id, active, last_active, type_, encryption, read_up_to});
+ init({id, account_id, jid_id, resource, active, last_active, type_, encryption, read_up_to});
}
}
@@ -164,12 +165,18 @@ public class Database : Qlite.Database {
}
}
- public Gee.List<Message> get_messages(Jid jid, Account account, int count, Message? before) {
+ public Gee.List<Message> get_messages(Jid jid, Account account, Message.Type? type, int count, Message? before) {
QueryBuilder select = message.select()
.with(message.counterpart_id, "=", get_jid_id(jid))
.with(message.account_id, "=", account.id)
.order_by(message.id, "DESC")
.limit(count);
+ if (jid.resourcepart != null) {
+ select.with(message.counterpart_resource, "=", jid.resourcepart);
+ }
+ if (type != null) {
+ select.with(message.type_, "=", (int) type);
+ }
if (before != null) {
select.with(message.time, "<", (long) before.time.to_unix());
}