mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Add AttachmentHeader to AuthorInfo
This way the UI can retrieve the author's avatar (if it exists).
This commit is contained in:
@@ -2,6 +2,7 @@ package org.briarproject.briar.api.avatar;
|
||||
|
||||
import org.briarproject.bramble.api.contact.Contact;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.ClientId;
|
||||
import org.briarproject.briar.api.media.Attachment;
|
||||
@@ -42,13 +43,14 @@ public interface AvatarManager {
|
||||
* or null if none is known.
|
||||
*/
|
||||
@Nullable
|
||||
AttachmentHeader getAvatarHeader(Contact c) throws DbException;
|
||||
AttachmentHeader getAvatarHeader(Transaction txn, Contact c)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Returns our current profile image header or null if none has been added.
|
||||
*/
|
||||
@Nullable
|
||||
AttachmentHeader getMyAvatarHeader() throws DbException;
|
||||
AttachmentHeader getMyAvatarHeader(Transaction txn) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the profile image attachment for the given header.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.briarproject.briar.api.identity;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.media.AttachmentHeader;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
@@ -20,14 +21,18 @@ public class AuthorInfo {
|
||||
private final Status status;
|
||||
@Nullable
|
||||
private final String alias;
|
||||
@Nullable
|
||||
private final AttachmentHeader avatarHeader;
|
||||
|
||||
public AuthorInfo(Status status, @Nullable String alias) {
|
||||
public AuthorInfo(Status status, @Nullable String alias,
|
||||
@Nullable AttachmentHeader avatarHeader) {
|
||||
this.status = status;
|
||||
this.alias = alias;
|
||||
this.avatarHeader = avatarHeader;
|
||||
}
|
||||
|
||||
public AuthorInfo(Status status) {
|
||||
this(status, null);
|
||||
this(status, null, null);
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
@@ -39,6 +44,11 @@ public class AuthorInfo {
|
||||
return alias;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public AttachmentHeader getAvatarHeader() {
|
||||
return avatarHeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = status.ordinal();
|
||||
@@ -52,6 +62,11 @@ public class AuthorInfo {
|
||||
AuthorInfo info = (AuthorInfo) o;
|
||||
//noinspection EqualsReplaceableByObjectsCall
|
||||
return status == info.status &&
|
||||
(alias == null ? info.alias == null : alias.equals(info.alias));
|
||||
// aliases are equal
|
||||
(alias == null ? info.alias == null :
|
||||
alias.equals(info.alias)) &&
|
||||
// avatars are equal
|
||||
(avatarHeader == null ? info.avatarHeader == null :
|
||||
avatarHeader.equals(info.avatarHeader));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.briarproject.briar.api.identity;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.identity.AuthorId;
|
||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
@NotNullByDefault
|
||||
@@ -18,4 +19,8 @@ public interface AuthorManager {
|
||||
*/
|
||||
AuthorInfo getAuthorInfo(Transaction txn, AuthorId a) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the {@link AuthorInfo} for the {@link LocalAuthor}.
|
||||
*/
|
||||
AuthorInfo getMyAuthorInfo(Transaction txn) throws DbException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user