Handle Ombi API object-format requestedUser field
Build and Push Docker Image / build (push) Successful in 47s
Licence Check / Licence compatibility and copyright header verification (push) Failing after 1m24s
CI / Security audit (push) Successful in 1m47s
CI / Swagger Validation & Coverage (push) Successful in 2m11s
CI / Tests & coverage (push) Successful in 2m27s
Build and Push Docker Image / build (push) Successful in 47s
Licence Check / Licence compatibility and copyright header verification (push) Failing after 1m24s
CI / Security audit (push) Successful in 1m47s
CI / Swagger Validation & Coverage (push) Successful in 2m11s
CI / Tests & coverage (push) Successful in 2m27s
The Ombi API returns requestedUser as an OmbiUser object instead of a string. Add extractRequestedUser helper to extract username from various fields (alias, userAlias, userName, normalizedUserName) with fallback to legacy string format. Update client and server routes to use the helper for consistent username extraction.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Helper functions for extracting user information from Ombi API responses.
|
||||
* The Ombi API returns requestedUser as an OmbiStore.Entities.OmbiUser object,
|
||||
* not a string, so we need to extract the username from the object.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extracts the username from an Ombi request object.
|
||||
* Handles both the OmbiUser object format and legacy string format.
|
||||
*
|
||||
* @param {Object} request - The Ombi request object
|
||||
* @returns {string} The extracted username, or empty string if not found
|
||||
*/
|
||||
function extractRequestedUser(request) {
|
||||
if (!request) return '';
|
||||
|
||||
// Handle object format: OmbiStore.Entities.OmbiUser
|
||||
if (request.requestedUser && typeof request.requestedUser === 'object') {
|
||||
// Priority: alias > userAlias > userName > normalizedUserName
|
||||
return request.requestedUser.alias ||
|
||||
request.requestedUser.userAlias ||
|
||||
request.requestedUser.userName ||
|
||||
request.requestedUser.normalizedUserName || '';
|
||||
}
|
||||
// Handle string format (fallback for compatibility)
|
||||
return request.requestedUser || request.requestedByAlias || '';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
extractRequestedUser
|
||||
};
|
||||
Reference in New Issue
Block a user