Skip to content

Commit

Permalink
Use error code name from server
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinBuira committed Nov 21, 2024
1 parent c9ba543 commit 7755a68
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
7 changes: 4 additions & 3 deletions app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -865,9 +865,6 @@ ApplicationWindow {
// just banner that we will try again
__notificationModel.addInfo( qsTr( "Somebody else is syncing, we will try again later" ) )
}
else if ( errorType === MM.SyncError.MonthlyContributorsLimitHit ){
monthlyContributorsLimitDialog.open()
}
else
{
syncFailedDialog.detailedText = qsTr( "Details" ) + ": " + errorMessage
Expand Down Expand Up @@ -904,6 +901,10 @@ ApplicationWindow {
storageLimitDialog.open()
}

function onMonthlyContributorLimitReached( uploadSize ) {
monthlyContributorsLimitDialog.open()
}

function onProjectLimitReached( maxProjects, errorMsg ) {
__merginApi.getUserInfo()
if (__merginApi.apiSupportsSubscriptions) {
Expand Down
10 changes: 0 additions & 10 deletions app/synchronizationerror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ SynchronizationError::ErrorType SynchronizationError::errorType( int errorCode,
// Project no longer exists / is on different server
return ErrorType::ProjectNotFound;
}
else if ( errorCode == 422 )
{
// Hit the maximun number of contributor per month
if ( errorMessage.contains( QStringLiteral( "Maximum number of workspace contributors" ) ) )
{
return ErrorType::MonthlyContributorsLimitHit;
}

return ErrorType::UnknownError;
}
else if ( errorCode >= 500 )
{
// Exceptions in server code or maintenance mode
Expand Down
1 change: 0 additions & 1 deletion app/synchronizationerror.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class SynchronizationError
ProjectNotFound,
VersionMismatch,
ServerError,
MonthlyContributorsLimitHit,
UnknownError
};
Q_ENUMS( ErrorType );
Expand Down
7 changes: 5 additions & 2 deletions core/merginapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2117,14 +2117,13 @@ void MerginApi::pushStartReplyFinished()
serverMsg = sSyncCanceledMessage;

QString code = extractServerErrorCode( data );
bool showLimitReachedDialog = EnumHelper::isEqual( code, ErrorCode::StorageLimitHit );

CoreUtils::log( "push " + projectFullName, QStringLiteral( "FAILED - %1. %2" ).arg( r->errorString(), serverMsg ) );

transaction.replyPushStart->deleteLater();
transaction.replyPushStart = nullptr;

if ( showLimitReachedDialog )
if ( EnumHelper::isEqual( code, ErrorCode::StorageLimitHit ) )
{
const QList<MerginFile> files = transaction.pushQueue;
qreal uploadSize = 0;
Expand All @@ -2144,6 +2143,10 @@ void MerginApi::pushStartReplyFinished()
deleteProject( projectNamespace, projectName, false );
}
}
else if ( EnumHelper::isEqual( code, ErrorCode::MonthlyContributorsLimitHit ) )
{
emit monthlyContributorLimitReached( serverMsg );
}
else
{
int httpCode = r->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt();
Expand Down
4 changes: 3 additions & 1 deletion core/merginapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ class ErrorCode
{
Unknown = 0,
ProjectsLimitHit,
StorageLimitHit
StorageLimitHit,
MonthlyContributorsLimitHit,
};
Q_ENUM( Value );
};
Expand Down Expand Up @@ -597,6 +598,7 @@ class MerginApi: public QObject
);

void storageLimitReached( qreal uploadSize );
void monthlyContributorLimitReached( const QString &message );
void projectLimitReached( int maxProjects, const QString &message );
void migrationRequested( const QString &version );
void notifySuccess( const QString &message );
Expand Down

1 comment on commit 7755a68

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

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

iOS - version 24.11.695811 just submitted!

Please sign in to comment.