forked from mirror/monocles_chat_clean
update fork #128
3 changed files with 15 additions and 6 deletions
Filter stories to only show those from the last 24 hours
commit
2623d8e574
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -322,7 +324,7 @@ public class StoriesActivity extends XmppActivity implements XmppConnectionServi
|
|||
} else {
|
||||
binding.storiesList.setVisibility(View.VISIBLE);
|
||||
}
|
||||
this.storyAdapter.notifyDataSetChanged();
|
||||
storyAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue