From aaa03cd809476349be7c5f52a12f638fc5dbd8bb Mon Sep 17 00:00:00 2001 From: akwizgran Date: Fri, 4 Dec 2020 12:10:10 +0000 Subject: [PATCH] Add method for UI and tests to get current timer. --- .../briar/api/autodelete/AutoDeleteManager.java | 7 +++++++ .../briar/autodelete/AutoDeleteManagerImpl.java | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/briar-api/src/main/java/org/briarproject/briar/api/autodelete/AutoDeleteManager.java b/briar-api/src/main/java/org/briarproject/briar/api/autodelete/AutoDeleteManager.java index 8599892d1..fac485335 100644 --- a/briar-api/src/main/java/org/briarproject/briar/api/autodelete/AutoDeleteManager.java +++ b/briar-api/src/main/java/org/briarproject/briar/api/autodelete/AutoDeleteManager.java @@ -24,6 +24,13 @@ public interface AutoDeleteManager { */ int MINOR_VERSION = 0; + /** + * Returns the auto-delete timer duration for the given contact. Use + * {@link #getAutoDeleteTimer(Transaction, ContactId, long)} if the timer + * will be used in an outgoing message. + */ + long getAutoDeleteTimer(Transaction txn, ContactId c) throws DbException; + /** * Returns the auto-delete timer duration for the given contact, for use in * a message with the given timestamp. The timestamp is stored. diff --git a/briar-core/src/main/java/org/briarproject/briar/autodelete/AutoDeleteManagerImpl.java b/briar-core/src/main/java/org/briarproject/briar/autodelete/AutoDeleteManagerImpl.java index e0644c63e..c07759092 100644 --- a/briar-core/src/main/java/org/briarproject/briar/autodelete/AutoDeleteManagerImpl.java +++ b/briar-core/src/main/java/org/briarproject/briar/autodelete/AutoDeleteManagerImpl.java @@ -78,6 +78,19 @@ class AutoDeleteManagerImpl db.removeGroup(txn, getGroup(c)); } + @Override + public long getAutoDeleteTimer(Transaction txn, ContactId c) + throws DbException { + try { + Group g = getGroup(db.getContact(txn, c)); + BdfDictionary meta = + clientHelper.getGroupMetadataAsDictionary(txn, g.getId()); + return meta.getLong(GROUP_KEY_TIMER, NO_AUTO_DELETE_TIMER); + } catch (FormatException e) { + throw new DbException(e); + } + } + @Override public long getAutoDeleteTimer(Transaction txn, ContactId c, long timestamp) throws DbException {