Skip to content

Conversation

jkoenig134
Copy link
Member

@jkoenig134 jkoenig134 commented Oct 1, 2025

Readiness checklist

  • I added/updated tests.
  • I ensured that the PR title is good enough for the changelog.
  • I labeled the PR.
  • I self-reviewed the PR.

Description

@jkoenig134 jkoenig134 added the refactoring Refactoring of code label Oct 1, 2025
@jkoenig134 jkoenig134 marked this pull request as draft October 1, 2025 14:37
Copy link
Contributor

@Milena-Czierlinski Milena-Czierlinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks overall good to me, so feel free to continue.

I know the naming isn't final yet, just wanted to already mention that now that we also flattened the peerSharingDetails, I think we can simplify forwardedSharingDetails e.g. to only forwardedDetails/forwardingDetails. "forwarded" and "sharing" sounds somewhat doppelt-gemoppelt.

Comment on lines 73 to 74
const deletionStatus = await attributesController.getForwardedSharingDetailsNotDeletedByRecipient(latestSharedVersion, requestInfo.peer);
if (deletionStatus) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that here you refactored the use of hasDeletionStatusUnequalDeletedByRecipient while in other places you kept that method. Should we do it coherently?

await this.updateAttributeUnsafe(attribute);
await this.upsertForwardedSharingDetailsForPeer(attribute, peer, sharingDetails);

// TODO: this event is strange, why do you want to listen on that?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that maybe we need to do some reloading in the app. If we don't see a reason for this event, I am fine with remving it.

public static readonly setting = new CoreIdHelper("LCLSET");

public static readonly attribute = new CoreIdHelper("ATT");
public static readonly attributeForwardedSharingDetails = new CoreIdHelper("ATTFSD");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decided to change the naming "forwardedSharingDetails" to "forwardedDetails/forwardingDetails" as @Milena-Czierlinski suggested, we must remember changing "ATTFSD" to "ATTFD" as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch :)

Comment on lines +135 to +136
// TODO: get the number of forwards
// TODO: filter for query.numberOfForwards
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be done in this PR?

);
expect(updatedAttribute.forwardedSharingDetails).toHaveLength(1);
expect(updatedAttribute.forwardedSharingDetails![0].deletionInfo).toBeUndefined();
expect(updatedAttribute.numberOfForwards).toBe(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This forwardedSharingDetail should be fetched and checked if its deletionInfo is undefined.

"forwardedSharingDetails.deletionInfo"?: string | string[];
"forwardedSharingDetails.deletionInfo.deletionStatus"?: string | string[];
"forwardedSharingDetails.deletionInfo.deletionDate"?: string | string[];
numberOfForwards?: string | string[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not number | number[] (as the type of numberOfForwards of the LocalAttributeDTO is number)?

Comment on lines 85 to 86
const updatedPredecessorForwardedSharingDetails = await consumptionController.attributes.getForwardedSharingDetailsForAttribute(databaseAttribute);
expect(updatedPredecessorForwardedSharingDetails[0].deletionInfo!.deletionStatus).toStrictEqual(EmittedAttributeDeletionStatus.DeletedByRecipient);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not about Attribute succession.

The same applies to other variable names in this file.

Suggested change
const updatedPredecessorForwardedSharingDetails = await consumptionController.attributes.getForwardedSharingDetailsForAttribute(databaseAttribute);
expect(updatedPredecessorForwardedSharingDetails[0].deletionInfo!.deletionStatus).toStrictEqual(EmittedAttributeDeletionStatus.DeletedByRecipient);
const updatedAttributeForwardedSharingDetails = await consumptionController.attributes.getForwardedSharingDetailsForAttribute(databaseAttribute);
expect(updatedAttributeForwardedSharingDetails[0].deletionInfo!.deletionStatus).toStrictEqual(EmittedAttributeDeletionStatus.DeletedByRecipient);

private expandForwardingPeers(localAttribute: OwnIdentityAttribute | OwnRelationshipAttribute | PeerRelationshipAttribute): string[] | undefined {
if (!localAttribute.forwardedSharingDetails || localAttribute.forwardedSharingDetails.length === 0) return;
private expandForwardingPeers(_localAttribute: OwnIdentityAttribute | OwnRelationshipAttribute | PeerRelationshipAttribute): string[] | undefined {
// TODO: enable when finding out how to proceed with this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be done in this PR?

Comment on lines +57 to +58
// this is not persisted, only used when returning attributes via the API
public numberOfForwards?: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This is the reason why numberOfForwards isn't added to ILocalAttribute and LocalAttributeJSON, right?
  2. Would it be appropriate here to add validation that numberOfForwards cannot be negative?
  3. Should numberOfForwards be added to the technicalProperties above?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema.ts needs to be updated.

Comment on lines +57 to +58
// this is not persisted, only used when returning attributes via the API
public numberOfForwards?: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this property must be removed here and add to OwnIdentityAttribute, OwnRelationshipAttribute and PeerRelationshipAttribute instead, as for the other LocalAttribute types this property should never be set. @Milena-Czierlinski What do you think?

@serialize()
public wasViewedAt?: CoreDate;

// this is not persisted, only used when returning attributes via the API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// this is not persisted, only used when returning attributes via the API
// this is not persisted, only used when returning Attributes via the API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Refactoring of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants