1
0
Fork 1

Remove quote fallbacks directly using the option

(cherry picked from commit 38ee9cae7bb10676d38b552546b13d9a7377ddc6)
This commit is contained in:
Stephen Paul Weber 2024-10-05 05:05:25 +02:00 committed by Arne
parent c78cef6164
commit f0b6d071ed

View file

@ -451,9 +451,9 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
if (replyId == null) return; if (replyId == null) return;
addPayload( addPayload(
new Element("reply", "urn:xmpp:reply:0") new Element("reply", "urn:xmpp:reply:0")
.setAttribute("to", replyTo.getCounterpart()) .setAttribute("to", replyTo.getCounterpart())
.setAttribute("id", replyId) .setAttribute("id", replyId)
); );
final Element fallback = new Element("fallback", "urn:xmpp:fallback:0").setAttribute("for", "urn:xmpp:reply:0"); final Element fallback = new Element("fallback", "urn:xmpp:fallback:0").setAttribute("for", "urn:xmpp:reply:0");
fallback.addChild("body", "urn:xmpp:fallback:0") fallback.addChild("body", "urn:xmpp:fallback:0")
@ -466,7 +466,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
} }
public void updateReaction(final Message reactTo, String emoji) { public void updateReaction(final Message reactTo, String emoji) {
Set<String> emojis = new HashSet<>(); Set<String> emojis = new HashSet<>();
if (conversation instanceof Conversation) emojis = ((Conversation) conversation).findReactionsTo(reactTo.replyId(), null); if (conversation instanceof Conversation) emojis = ((Conversation) conversation).findReactionsTo(reactTo.replyId(), null);
emojis.remove(getBody(true)); emojis.remove(getBody(true));
emojis.add(emoji); emojis.add(emoji);
@ -526,7 +526,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
if (this.conversation.getMode() == Conversation.MODE_SINGLE) { if (this.conversation.getMode() == Conversation.MODE_SINGLE) {
if (this.trueCounterpart != null) { if (this.trueCounterpart != null) {
return this.conversation.getAccount().getRoster() return this.conversation.getAccount().getRoster()
.getContact(this.trueCounterpart); .getContact(this.trueCounterpart);
} }
return this.conversation.getContact(); return this.conversation.getContact();
@ -691,7 +691,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
} }
public String getOccupantId() { public String getOccupantId() {
return this.occupantId; return occupantId;
} }
public void setMucUser(MucOptions.User user) { public void setMucUser(MucOptions.User user) {
@ -703,8 +703,8 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
final MucOptions.User thisUser = this.user == null ? null : this.user.get(); final MucOptions.User thisUser = this.user == null ? null : this.user.get();
final MucOptions.User otherUser = otherMessage.user == null ? null : otherMessage.user.get(); final MucOptions.User otherUser = otherMessage.user == null ? null : otherMessage.user.get();
return return
(thisUser != null && thisUser == otherUser) || (thisUser != null && thisUser == otherUser) ||
(getOccupantId() != null && getOccupantId().equals(otherMessage.getOccupantId())); (getOccupantId() != null && getOccupantId().equals(otherMessage.getOccupantId()));
} }
public String getErrorMessage() { public String getErrorMessage() {
@ -1023,7 +1023,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
private static boolean isEncryptionMergeable(final int a, final int b) { private static boolean isEncryptionMergeable(final int a, final int b) {
return a == b return a == b
&& Arrays.asList(ENCRYPTION_NONE, ENCRYPTION_DECRYPTED, ENCRYPTION_AXOLOTL) && Arrays.asList(ENCRYPTION_NONE, ENCRYPTION_DECRYPTED, ENCRYPTION_AXOLOTL)
.contains(a); .contains(a);
} }
public void setCounterparts(List<MucOptions.User> counterparts) { public void setCounterparts(List<MucOptions.User> counterparts) {
@ -1102,27 +1102,27 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
spannableBody.setSpan(PLAIN_TEXT_SPAN, 0, spannableBody.length(), 0); // Let adapter know it can do more formatting spannableBody.setSpan(PLAIN_TEXT_SPAN, 0, spannableBody.length(), 0); // Let adapter know it can do more formatting
} else { } else {
SpannableStringBuilder spannable = new SpannableStringBuilder(Html.fromHtml( SpannableStringBuilder spannable = new SpannableStringBuilder(Html.fromHtml(
MessageUtils.filterLtrRtl(html.toString()).trim(), MessageUtils.filterLtrRtl(html.toString()).trim(),
Html.FROM_HTML_MODE_COMPACT, Html.FROM_HTML_MODE_COMPACT,
(source) -> { (source) -> {
try { try {
if (thumbnailer == null || source == null) { if (thumbnailer == null || source == null) {
return fallbackImg; return fallbackImg;
} }
Cid cid = BobTransfer.cid(new URI(source)); Cid cid = BobTransfer.cid(new URI(source));
if (cid == null) { if (cid == null) {
return fallbackImg; return fallbackImg;
} }
Drawable thumbnail = thumbnailer.getThumbnail(cid); Drawable thumbnail = thumbnailer.getThumbnail(cid);
if (thumbnail == null) { if (thumbnail == null) {
return fallbackImg; return fallbackImg;
} }
return thumbnail; return thumbnail;
} catch (final URISyntaxException e) { } catch (final URISyntaxException e) {
return fallbackImg; return fallbackImg;
} }
}, },
(opening, tag, output, xmlReader) -> {} (opening, tag, output, xmlReader) -> {}
)); ));
// Make images clickable and long-clickable with BetterLinkMovementMethod // Make images clickable and long-clickable with BetterLinkMovementMethod
@ -1285,7 +1285,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
public List<URI> getLinks() { public List<URI> getLinks() {
SpannableStringBuilder text = new SpannableStringBuilder( SpannableStringBuilder text = new SpannableStringBuilder(
getBody().replaceAll("^>.*", "") // Remove quotes getBody(true).replaceAll("^>.*", "") // Remove quotes
); );
return MyLinkify.extractLinks(text).stream().map((url) -> { return MyLinkify.extractLinks(text).stream().map((url) -> {
try { try {
@ -1316,7 +1316,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
} }
public List<Element> getPayloads() { public List<Element> getPayloads() {
return new ArrayList<>(this.payloads); return new ArrayList<>(this.payloads);
} }
public List<Element> getFallbacks(String... includeFor) { public List<Element> getFallbacks(String... includeFor) {
@ -1354,7 +1354,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
} }
return null; return null;
} }
public List<Element> getCommands() { public List<Element> getCommands() {
if (this.payloads == null) return null; if (this.payloads == null) return null;
@ -1445,8 +1445,8 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
protected List<Element> getSims() { protected List<Element> getSims() {
return payloads.stream().filter(el -> return payloads.stream().filter(el ->
el.getName().equals("reference") && el.getNamespace().equals("urn:xmpp:reference:0") && el.getName().equals("reference") && el.getNamespace().equals("urn:xmpp:reference:0") &&
el.findChild("media-sharing", "urn:xmpp:sims:1") != null el.findChild("media-sharing", "urn:xmpp:sims:1") != null
).collect(Collectors.toList()); ).collect(Collectors.toList());
} }
@ -1701,8 +1701,8 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
for (Cid cid : cids) { for (Cid cid : cids) {
file.addChild("hash", "urn:xmpp:hashes:2") file.addChild("hash", "urn:xmpp:hashes:2")
.setAttribute("algo", CryptoHelper.multihashAlgo(cid.getType())) .setAttribute("algo", CryptoHelper.multihashAlgo(cid.getType()))
.setContent(Base64.encodeToString(cid.getHash(), Base64.NO_WRAP)); .setContent(Base64.encodeToString(cid.getHash(), Base64.NO_WRAP));
} }
} }
@ -1732,11 +1732,11 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
if (sims == null) toSims(); if (sims == null) toSims();
Element file = getFileElement(); Element file = getFileElement();
file.addChild( file.addChild(
new Element("thumbnail", "urn:xmpp:thumbs:1") new Element("thumbnail", "urn:xmpp:thumbs:1")
.setAttribute("width", Integer.toString(width)) .setAttribute("width", Integer.toString(width))
.setAttribute("height", Integer.toString(height)) .setAttribute("height", Integer.toString(height))
.setAttribute("type", mimeType) .setAttribute("type", mimeType)
.setAttribute("uri", uri) .setAttribute("uri", uri)
); );
} }