Skip to content

Commit

Permalink
Restricts forum synchronization to 1 year by default
Browse files Browse the repository at this point in the history
  • Loading branch information
zapek committed Mar 20, 2024
1 parent 6abd1f2 commit 8025224
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ private void syncMessages(PeerConnection peerConnection)
{
// Request new messages for all subscribed groups
findAllSubscribedGroups().forEach(forumGroupItem -> {
var gxsSyncMessageRequestItem = new GxsSyncMessageRequestItem(forumGroupItem.getGxsId(), gxsUpdateService.getLastPeerMessagesUpdate(peerConnection.getLocation(), forumGroupItem.getGxsId(), getServiceType()));
log.debug("Asking {} for new messages in {} since {} for {}", peerConnection, gxsSyncMessageRequestItem.getGroupId(), log.isDebugEnabled() ? Instant.ofEpochSecond(gxsSyncMessageRequestItem.getLastUpdated()) : null, getServiceType());
var gxsSyncMessageRequestItem = new GxsSyncMessageRequestItem(forumGroupItem.getGxsId(), gxsUpdateService.getLastPeerMessagesUpdate(peerConnection.getLocation(), forumGroupItem.getGxsId(), getServiceType()), ChronoUnit.YEARS.getDuration());
log.debug("Asking {} for new messages in {} since {} for {}", peerConnection, gxsSyncMessageRequestItem.getGroupId(), log.isDebugEnabled() ? Instant.ofEpochSecond(gxsSyncMessageRequestItem.getCreateSince()) : null, getServiceType());
peerConnectionManager.writeItem(peerConnection, gxsSyncMessageRequestItem, this);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ private boolean areMessageUpdatesAvailableForPeer(GxsId groupId, Instant lastPee
return false;
}

var group = groupList.get(0);
var group = groupList.getFirst();
return group.isSubscribed() &&
group.getLastPosted() != null &&
lastPeerUpdate.isBefore(group.getLastPosted()) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import io.xeres.app.xrs.serialization.RsSerialized;
import io.xeres.common.id.GxsId;

import java.time.Duration;
import java.time.Instant;
import java.util.stream.Stream;

import static io.xeres.app.xrs.serialization.TlvType.STR_HASH_SHA1;

Expand Down Expand Up @@ -34,10 +36,18 @@ public GxsSyncMessageRequestItem()
{
}

public GxsSyncMessageRequestItem(GxsId groupId, Instant lastUpdated)
public GxsSyncMessageRequestItem(GxsId groupId, Instant lastUpdated, Duration limit)
{
this.groupId = groupId;
this.lastUpdated = (int) lastUpdated.getEpochSecond();
createSince = (int) getMostRecent(lastUpdated, limit).getEpochSecond();
}

private Instant getMostRecent(Instant last, Duration limit)
{
return Stream.of(Instant.now().minus(limit), last)
.max(Instant::compareTo)
.get();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/resources/view/forum/forumview.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<FontAwesomeIconView glyphName="ENVELOPE" glyphSize="14"/>
</graphic>
</TreeTableColumn>-->
<TreeTableColumn fx:id="treeTableSubject" minWidth="80" prefWidth="220" text="%forum.view.header.subject"/>
<TreeTableColumn fx:id="treeTableSubject" minWidth="80" prefWidth="320" text="%forum.view.header.subject"/>
<TreeTableColumn fx:id="treeTableAuthor" minWidth="40" prefWidth="100" text="%forum.view.header.author"/>
<TreeTableColumn fx:id="treeTableDate" minWidth="40" prefWidth="140" text="%forum.view.header.date"/>
</columns>
Expand Down

0 comments on commit 8025224

Please sign in to comment.