Skip to content

Commit

Permalink
Allow force-refreshing prekeys
Browse files Browse the repository at this point in the history
  • Loading branch information
rubdos committed Mar 13, 2024
1 parent e25b457 commit 836a963
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libsignal-service/src/account_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl<Service: PushService> AccountManager<Service> {
service_id_type: ServiceIdType,
csprng: &mut R,
use_last_resort_key: bool,
force: bool,
) -> Result<(), ServiceError> {
let prekey_status = match self
.service
Expand All @@ -132,11 +133,18 @@ impl<Service: PushService> AccountManager<Service> {
};
tracing::trace!("Remaining pre-keys on server: {:?}", prekey_status);

// XXX We should honestly compare the pre-key count with the number of pre-keys we have
// locally. If we have more than the server, we should upload them.
// Currently the trait doesn't allow us to do that, so we just upload the batch size and
// pray.
if prekey_status.count >= PRE_KEY_MINIMUM
&& prekey_status.pq_count >= PRE_KEY_MINIMUM
{
tracing::info!("Available keys sufficient");
return Ok(());
if !force {
tracing::debug!("Available keys sufficient");
return Ok(());
}
tracing::info!("Available keys sufficient; forcing refresh.");
}

let identity_key_pair = protocol_store
Expand Down

0 comments on commit 836a963

Please sign in to comment.