@@ -58,15 +58,18 @@ class PublisherBackend {
5858 return visible! ;
5959 }
6060
61- /// Loads a publisher. Returns `null` if it does not exists, or is blocked (not visible) .
62- Future <Publisher ?> getPublisher (String publisherId) async {
61+ /// Loads a [Publisher] entity or `null` if there is no such entity .
62+ Future <Publisher ?> lookupPublisher (String publisherId) async {
6363 checkPublisherIdParam (publisherId);
6464 final pKey = _db.emptyKey.append (Publisher , id: publisherId);
65- final p = await _db.lookupOrNull <Publisher >(pKey);
66- if (p != null && p.isBlocked) {
67- return null ;
68- }
69- return p;
65+ return await _db.lookupOrNull <Publisher >(pKey);
66+ }
67+
68+ /// Loads a [Publisher] entity or `null` if there is no such entity,
69+ /// or if the entity is not listed / visible.
70+ Future <Publisher ?> getListedPublisher (String publisherId) async {
71+ final p = await lookupPublisher (publisherId);
72+ return p == null || p.isUnlisted ? null : p;
7073 }
7174
7275 /// List publishers (in no specific order, it will be listed by their
@@ -114,7 +117,7 @@ class PublisherBackend {
114117 publishers.sort ((a, b) => a.publisherId.compareTo (b.publisherId));
115118 return PublisherPage (
116119 publishers: publishers
117- .where ((p) => ! p.isBlocked )
120+ .where ((p) => p.isVisible )
118121 .map ((p) => PublisherSummary (
119122 publisherId: p.publisherId,
120123 created: p.created! ,
@@ -134,7 +137,6 @@ class PublisherBackend {
134137
135138 /// Whether the User [userId] has admin permissions on the publisher.
136139 Future <bool > isMemberAdmin (Publisher publisher, String ? userId) async {
137- if (publisher.isBlocked) return false ;
138140 if (publisher.isModerated) return false ;
139141 if (userId == null ) return false ;
140142 final member = await getPublisherMember (publisher, userId);
@@ -250,7 +252,7 @@ class PublisherBackend {
250252 /// Gets the publisher data
251253 Future <api.PublisherInfo > getPublisherInfo (String publisherId) async {
252254 checkPublisherIdParam (publisherId);
253- final p = await getPublisher (publisherId);
255+ final p = await getListedPublisher (publisherId);
254256 if (p == null ) {
255257 throw NotFoundException ('Publisher $publisherId does not exists.' );
256258 }
@@ -598,13 +600,13 @@ Future<Publisher> requirePublisherAdmin(
598600 String ? publisherId, String userId) async {
599601 ArgumentError .checkNotNull (userId, 'userId' );
600602 ArgumentError .checkNotNull (publisherId, 'publisherId' );
601- final p = await publisherBackend.getPublisher (publisherId! );
602- if (p == null ) {
603- throw NotFoundException ('Publisher $publisherId does not exists.' );
604- }
605- if (p.isModerated) {
603+ final p = await publisherBackend.lookupPublisher (publisherId! );
604+ if (p != null && p.isModerated) {
606605 throw ModeratedException .publisher (publisherId);
607606 }
607+ if (p == null || p.isUnlisted) {
608+ throw NotFoundException ('Publisher $publisherId does not exists.' );
609+ }
608610
609611 final member = await publisherBackend._db
610612 .lookupOrNull <PublisherMember >(p.key.append (PublisherMember , id: userId));
0 commit comments