update fork #128

Manually merged
tristan merged 181 commits from mirror/monocles_chat_clean:master into master 2026-01-23 14:02:38 +01:00
3 changed files with 15 additions and 6 deletions
Showing only changes of commit 2623d8e574 - Show all commits

Filter stories to only show those from the last 24 hours

Arne 2025-12-31 14:29:15 +01:00

View file

@ -727,8 +727,14 @@ public class IqGenerator extends AbstractGenerator {
}
public Iq createStoriesNode() {
final Data data = Data.create(null, defaultStoriesConfiguration());
return publishPubsubConfiguration(null, Namespace.PUBSUB_STORIES, data);
final Iq iq = new Iq(Iq.Type.SET);
final Element pubsub = iq.addChild("pubsub", Namespace.PUBSUB);
pubsub.addChild("create").setAttribute("node", Namespace.PUBSUB_STORIES);
final Element configure = pubsub.addChild("configure");
// Correctly use the 'pubsub#node_config' namespace
final Data data = Data.create("http://jabber.org/protocol/pubsub#node_config", defaultStoriesConfiguration());
configure.addChild(data);
return iq;
}
public Iq requestPubsubConfiguration(Jid jid, String node) {

View file

@ -7771,7 +7771,8 @@ public class XmppConnectionService extends Service {
}
return;
}
final Iq packet = getIqGenerator().publishStory(url, type, title, null);
final Bundle options = retry ? IqGenerator.defaultStoriesConfiguration() : null;
final Iq packet = getIqGenerator().publishStory(url, type, title, options);
sendIqPacket(account, packet, response -> {
if (response.getType() == Iq.Type.RESULT) {
if (callback != null) {
@ -7780,9 +7781,9 @@ public class XmppConnectionService extends Service {
} else if (retry && PublishOptions.preconditionNotMet(response)) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": stories node does not exist. creating it");
final Iq createRequest = getIqGenerator().createStoriesNode();
createRequest.setTo(account.getJid().asBareJid());
sendIqPacket(account, createRequest, createResponse -> {
if (createResponse.getType() == Iq.Type.RESULT) {
// After successfully creating the node, retry publishing without the config options
publishStory(account, url, type, title, false, callback);
} else {
if (callback != null) {

View file

@ -306,8 +306,10 @@ public class StoriesActivity extends XmppActivity implements XmppConnectionServi
return;
}
this.stories.clear();
long twentyFourHoursAgo = System.currentTimeMillis() - 86400000;
this.stories.addAll(
this.xmppConnectionService.getStories().stream()
.filter(s -> s.getPublished() >= twentyFourHoursAgo)
.collect(Collectors.toMap(
story -> story.getContact().asBareJid(),
story -> story,
@ -315,14 +317,14 @@ public class StoriesActivity extends XmppActivity implements XmppConnectionServi
))
.values()
);
Collections.sort(this.stories, (a,b) -> Long.compare(b.getPublished(), a.getPublished()));
Collections.sort(this.stories, (a, b) -> Long.compare(b.getPublished(), a.getPublished()));
if (this.stories.isEmpty()) {
binding.storiesList.setVisibility(View.GONE);
} else {
binding.storiesList.setVisibility(View.VISIBLE);
}
this.storyAdapter.notifyDataSetChanged();
storyAdapter.notifyDataSetChanged();
}
@Override