Skip to content

Refactor/removal of typed object form endpoint#421

Merged
zurekz merged 11 commits into
develfrom
refactor/removal_of_TypedObject_form_endpoint
May 8, 2026
Merged

Refactor/removal of typed object form endpoint#421
zurekz merged 11 commits into
develfrom
refactor/removal_of_TypedObject_form_endpoint

Conversation

@Uriagat
Copy link
Copy Markdown
Member

@Uriagat Uriagat commented May 5, 2026

No description provided.

@Uriagat Uriagat requested review from imaTik0 and zurekz May 5, 2026 12:19
@Uriagat Uriagat self-assigned this May 5, 2026
Comment on lines -114 to +112
auto buffer = utils::Utils::stringify(data);
auto buffer = utils::Utils::stringifyVar(data.toJSON());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My suggestion here would be to rename T.toJSON() to T.toJSONObj(), since the function returns an object. Additionally, I would extend type T with a Buffer T.serialize() function (that whould use toJSONObj() internally), which would simplify this function (and similar ones):

Pson::BinaryString getSign(const T& data, const privmx::crypto::PrivateKey& privKey) {
    auto buffer = utils::Utils::stringify(data);
    auto buffer = utils::Utils::stringifyVar(data.toJSON());
    return Pson::BinaryString(privKey.signToCompactSignatureWithHash(buffer));
}

to the following form:

Pson::BinaryString getSign(const T& data, const privmx::crypto::PrivateKey& privKey) {
    return Pson::BinaryString(privKey.signToCompactSignatureWithHash(data.serialize()));
}

The toJSONObj() function would still remain part of the interface, since it is needed in many places, but its name would also be more descriptive.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Create seperated issue with adding hepler metods 'serialize' and 'deserialize' for JSON_STRUCT

core::DecryptedModuleDataV4()
);

template<typename ModuleStructAsTypedObj>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't this name be changed?

core::DecryptedModuleDataV5()
);

template<typename ModuleStructAsTypedObj>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't this name be changed?

DECLARE_ENDPOINT_EXCEPTION(EndpointLibException, OperationCancelledException, "Operation canceled", 0x0005)
DECLARE_ENDPOINT_EXCEPTION(EndpointLibException, NotImplementedException, "Not implemented", 0x0006)
DECLARE_ENDPOINT_EXCEPTION(EndpointLibException, InvalidVersionFormatException, "Invalid version format", 0x0007);
DECLARE_ENDPOINT_EXCEPTION(EndpointLibException, JSONParseException, "JSON Parse", 0x0008);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be: "Cannot parse JSON"

DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, UnknownModuleFormatException, "Unknown module format", 0x0023)
DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, InvalidSubscriptionQueryException, "Invalid subscriptionQuery", 0x00024)
DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, InvalidSingletonsHolderStateException, "Invalid Singletons Holder state", 0x00025)
DECLARE_ENDPOINT_EXCEPTION(EndpointCoreException, MissingBridgeIdentityException, "Missing Bridge Identity Exception", 0x00026)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should not have "Exception" word in description.

Comment thread endpoint/thread/src/ThreadApiImpl.cpp Outdated
Comment on lines +297 to +298
server::ThreadMessageGetModel model;
model.messageId = messageId;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use one-line initialization.

Comment on lines +311 to +312
server::ThreadMessagesGetModel model;
model.threadId = threadId;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use one-line initialization.

Comment thread endpoint/thread/src/ThreadApiImpl.cpp Outdated
Comment on lines +360 to +361
server::ThreadMessageDeleteModel model;
model.messageId = messageId;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use one-line initialization.

Comment on lines +371 to +372
server::ThreadMessageGetModel model;
model.messageId = messageId;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use one-line initialization.

Comment thread endpoint/thread/src/ThreadApiImpl.cpp Outdated
Comment on lines +1174 to +1176
thread::server::ThreadGetModel params;
params.threadId = moduleId;
auto thread = _serverApi.threadGet(params).thread;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use one-line initialization.

@Uriagat Uriagat requested a review from zurekz May 7, 2026 12:11
@Uriagat Uriagat mentioned this pull request May 7, 2026
@zurekz zurekz merged commit 0316ac7 into devel May 8, 2026
1 of 2 checks passed
@zurekz zurekz deleted the refactor/removal_of_TypedObject_form_endpoint branch May 8, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants