include membersOnlyNonAnonymous in chat info

This commit is contained in:
Daniel Gultsch 2023-03-23 12:36:33 +01:00
parent 4fd96e740f
commit da528776db
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2
2 changed files with 16 additions and 7 deletions

View file

@ -193,6 +193,7 @@ public abstract class ChatDao {
protected abstract void deleteStatusCodes(final long chatId); protected abstract void deleteStatusCodes(final long chatId);
// TODO select vCardPhoto for c.type='MUC_PM' // TODO select vCardPhoto for c.type='MUC_PM'
// TODO select real name for `sender` in membersOnlyNonAnonymous MUCs
@Transaction @Transaction
@Query( @Query(
"SELECT c.id,c.accountId,c.address,c.type,m.sentAt,m.outgoing,m.latestVersion as" "SELECT c.id,c.accountId,c.address,c.type,m.sentAt,m.outgoing,m.latestVersion as"
@ -210,11 +211,14 @@ public abstract class ChatDao {
+ " WHEN c.type='INDIVIDUAL' THEN (SELECT vCardPhoto FROM presence WHERE" + " WHEN c.type='INDIVIDUAL' THEN (SELECT vCardPhoto FROM presence WHERE"
+ " accountId=c.accountId AND address=c.address AND vCardPhoto NOT NULL LIMIT 1)" + " accountId=c.accountId AND address=c.address AND vCardPhoto NOT NULL LIMIT 1)"
+ " ELSE NULL END) as vCardPhoto,(SELECT thumb_id FROM avatar WHERE" + " ELSE NULL END) as vCardPhoto,(SELECT thumb_id FROM avatar WHERE"
+ " avatar.accountId=c.accountId AND avatar.address=c.address) as avatar FROM CHAT" + " avatar.accountId=c.accountId AND avatar.address=c.address) as avatar,(CASE WHEN"
+ " c LEFT JOIN message m ON (m.id = (SELECT id FROM message WHERE chatId=c.id" + " c.type='MUC' THEN (SELECT count(distinct(df.feature)) == 2 FROM disco_item di"
+ " ORDER by receivedAt DESC LIMIT 1)) WHERE (:accountId IS NULL OR" + " JOIN disco_feature df ON di.discoId = df.discoId WHERE di.address=c.address AND"
+ " c.accountId=:accountId) AND (:groupId IS NULL OR (c.address IN(SELECT" + " df.feature IN('muc_membersonly','muc_nonanonymous')) ELSE 0 END) as"
+ " roster.address FROM roster JOIN roster_group ON" + " membersOnlyNonAnonymous FROM CHAT c LEFT JOIN message m ON (m.id = (SELECT id"
+ " FROM message WHERE chatId=c.id ORDER by receivedAt DESC LIMIT 1)) WHERE"
+ " (:accountId IS NULL OR c.accountId=:accountId) AND (:groupId IS NULL OR"
+ " (c.address IN(SELECT roster.address FROM roster JOIN roster_group ON"
+ " roster.id=roster_group.rosterItemId WHERE roster.accountId=c.accountId AND" + " roster.id=roster_group.rosterItemId WHERE roster.accountId=c.accountId AND"
+ " roster_group.groupId=:groupId) OR c.address IN(SELECT address FROM bookmark" + " roster_group.groupId=:groupId) OR c.address IN(SELECT address FROM bookmark"
+ " JOIN bookmark_group ON bookmark.id=bookmark_group.bookmarkId WHERE" + " JOIN bookmark_group ON bookmark.id=bookmark_group.bookmarkId WHERE"
@ -231,8 +235,11 @@ public abstract class ChatDao {
+ " disco_identity identity ON disco_item.discoId=identity.discoId WHERE" + " disco_identity identity ON disco_item.discoId=identity.discoId WHERE"
+ " disco_item.accountId=c.accountId AND disco_item.address=c.address LIMIT 1) as" + " disco_item.accountId=c.accountId AND disco_item.address=c.address LIMIT 1) as"
+ " discoIdentityName,(SELECT name FROM bookmark WHERE" + " discoIdentityName,(SELECT name FROM bookmark WHERE"
+ " bookmark.accountId=c.accountId AND bookmark.address=c.address) as bookmarkName" + " bookmark.accountId=c.accountId AND bookmark.address=c.address) as"
+ " FROM chat c WHERE c.id=:chatId") + " bookmarkName,(CASE WHEN c.type='MUC' THEN (SELECT count(distinct(df.feature))"
+ " == 2 FROM disco_item di JOIN disco_feature df ON di.discoId = df.discoId WHERE"
+ " di.address=c.address AND df.feature IN('muc_membersonly','muc_nonanonymous'))"
+ " ELSE 0 END) as membersOnlyNonAnonymous FROM chat c WHERE c.id=:chatId")
public abstract LiveData<ChatInfo> getChatInfo(final long chatId); public abstract LiveData<ChatInfo> getChatInfo(final long chatId);
public PagingSource<Integer, ChatOverviewItem> getChatOverview(final ChatFilter chatFilter) { public PagingSource<Integer, ChatOverviewItem> getChatOverview(final ChatFilter chatFilter) {

View file

@ -14,6 +14,8 @@ public class ChatInfo {
public String discoIdentityName; public String discoIdentityName;
public String bookmarkName; public String bookmarkName;
public boolean membersOnlyNonAnonymous;
public String name() { public String name() {
return switch (type) { return switch (type) {
case MUC -> mucName(); case MUC -> mucName();