Skip to content

Commit

Permalink
Merge pull request #1627 from NYPL-Simplified/iOS-586
Browse files Browse the repository at this point in the history
iOS-586 Implement logic to add expiration date to banned books and remove expired banned books
  • Loading branch information
ExplorerNautilus authored Dec 7, 2023
2 parents d4ead68 + 0a65d96 commit 8ef1a3f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 10 deletions.
10 changes: 5 additions & 5 deletions Simplified.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2556,8 +2556,8 @@
73FB0AC824EB403D0072E430 /* NYPLBookContentTypeConverter.swift */,
1139DA6319C7755D00A07810 /* NYPLBookCoverRegistry.h */,
1139DA6419C7755D00A07810 /* NYPLBookCoverRegistry.m */,
1164F104199AC236009BF8BF /* NYPLBookLocation.h */,
1164F105199AC236009BF8BF /* NYPLBookLocation.m */,
1164F104199AC236009BF8BF /* NYPLBookLocation.h */,
11616E0F196B0531003D60D9 /* NYPLBookRegistry.h */,
11616E10196B0531003D60D9 /* NYPLBookRegistry.m */,
112C694B197301FE00C48F95 /* NYPLBookRegistryRecord.h */,
Expand Down Expand Up @@ -4706,7 +4706,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Simplified/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = 7262U6ST2R;
ENABLE_BITCODE = NO;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
Expand Down Expand Up @@ -4754,7 +4754,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Simplified/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = 7262U6ST2R;
ENABLE_BITCODE = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down Expand Up @@ -5014,7 +5014,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Simplified/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = 7262U6ST2R;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down Expand Up @@ -5064,7 +5064,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Simplified/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = 7262U6ST2R;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Simplified/AppInfrastructure/Simplified-Prefix.pch";
Expand Down
6 changes: 6 additions & 0 deletions Simplified/Book/Models/NYPLBookRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ typedef NS_ENUM(NSInteger, NYPLBookState);
*/
- (void)syncWithStandardAlertsOnCompletion;

/**
Goes through all books in registry and remove the expired banned books distributed by Axis 360.
@note: Only call this function if the library does not require authentication
*/
- (void)removeExpiredBannedBooks;

// Adds a book to the book registry until it is manually removed. It allows the application to
// present information about obtained books when offline. Attempting to add a book already present
// will overwrite the existing book as if |updateBook:| were called. The location may be nil. The
Expand Down
21 changes: 21 additions & 0 deletions Simplified/Book/Models/NYPLBookRegistry.m
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,27 @@ - (void)syncWithStandardAlertsOnCompletion
}];
}

- (void)removeExpiredBannedBooks
{
@synchronized(self) {
NSMutableArray *booksToRemove = [[NSMutableArray alloc] init];
for (NSString *bookIdentifer in self.identifiersToRecords) {
NYPLBookRegistryRecord *record = self.identifiersToRecords[bookIdentifer];
// Add the book to remove list if it is distributed by Axis360 and expired
if([record.book.defaultAcquisition.type isEqualToString:ContentTypeAxis360]) {
if (record.book.defaultAcquisition.availability.until &&
[record.book.defaultAcquisition.availability.until compare:[NSDate date]] == NSOrderedAscending) {
[booksToRemove addObject:bookIdentifer];
}
}
}
for (NSString *bookIdentifier in booksToRemove) {
[self removeBookForIdentifier:bookIdentifier];
}
[self save];
}
}

- (void)addBook:(NYPLBook *const)book
location:(NYPLBookLocation *const)location
state:(NSInteger)state
Expand Down
3 changes: 3 additions & 0 deletions Simplified/Catalog/NYPLCatalogFeedViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ - (void)viewDidLoad
}

[[NYPLBookRegistry sharedRegistry] justLoad];
if (!NYPLUserAccount.sharedAccount.requiresUserAuthentication) {
[[NYPLBookRegistry sharedRegistry] removeExpiredBannedBooks];
}
UIApplicationState applicationState = [[UIApplication sharedApplication] applicationState];
if (applicationState == UIApplicationStateActive) {
[self syncBookRegistryForNewFeed];
Expand Down
12 changes: 7 additions & 5 deletions scripts/firebase-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ else
fatal "Unable to upload to firebase: missing ad-hoc export!"
fi

# Disabling the IPA upload to firebase because we encountered authentication error,
# possibly due to `token` authentication is deprecated.
# upload app binary
echo "Using ipa at $IPA_PATH"
firebase appdistribution:distribute \
--token "${FIREBASE_TOKEN}" \
--app "${FIREBASE_APP_ID}" \
"${IPA_PATH}"
#echo "Using ipa at $IPA_PATH"
#firebase appdistribution:distribute \
# --token "${FIREBASE_TOKEN}" \
# --app "${FIREBASE_APP_ID}" \
# "${IPA_PATH}"

# upload symbols
./scripts/firebase-upload-symbols.sh "$APPNAME_PARAM" "$DSYMS_PATH"
Expand Down

0 comments on commit 8ef1a3f

Please sign in to comment.