Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 43c94e3

Browse files
committed
Add option to hide listings
1 parent 17b50f6 commit 43c94e3

File tree

5 files changed

+37
-21
lines changed

5 files changed

+37
-21
lines changed

api/restapi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ def parse_listings(listings):
234234
"origin": str(CountryCode.Name(l.origin)),
235235
"ships_to": [],
236236
"last_modified": l.last_modified,
237-
"pinned": l.pinned
237+
"pinned": l.pinned,
238+
"hidden": l.hidden
238239
}
239240
if l.contract_type != 0:
240241
listing_json["contract_type"] = str(objects.Listings.ContractType.Name(l.contract_type))
@@ -552,6 +553,7 @@ def set_contract(self, request):
552553
c.create(
553554
str_to_bool(request.args["pinned"][0]) if "pinned" in request.args else False,
554555
int(request.args["max_quantity"][0]) if "max_quantity" in request.args else 999999,
556+
str_to_bool(request.args["hidden"][0]) if "hidden" in request.args else False,
555557
str(request.args["expiration_date"][0]),
556558
request.args["metadata_category"][0],
557559
request.args["title"][0].decode("utf8"),

market/contracts.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def __init__(self, database, contract=None, hash_value=None, testnet=False):
9696
def create(self,
9797
pinned,
9898
max_quantity,
99+
hidden,
99100
expiration_date,
100101
metadata_category,
101102
title,
@@ -154,7 +155,8 @@ def create(self,
154155
"category_sub": "fixed price",
155156
"last_modified": int(time.time()),
156157
"pinned": pinned,
157-
"max_quantity": max_quantity
158+
"max_quantity": max_quantity,
159+
"hidden": hidden
158160
},
159161
"id": {
160162
"guid": self.keychain.guid.encode("hex"),
@@ -1074,6 +1076,7 @@ def save(self):
10741076
data.contract_type = listings.SERVICE
10751077
data.last_modified = int(time.time())
10761078
data.pinned = self.contract["vendor_offer"]["listing"]["metadata"]["pinned"]
1079+
data.hidden = self.contract["vendor_offer"]["listing"]["metadata"]["hidden"]
10771080

10781081
# save the mapping of the contract file path and contract hash in the database
10791082
self.db.filemap.insert(data.contract_hash.encode("hex"), file_path[len(DATA_FOLDER):])

market/protocol.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ def rpc_get_listings(self, sender):
113113
l.ParseFromString(self.db.listings.get_proto())
114114
l.handle = p.handle
115115
l.avatar_hash = p.avatar_hash
116+
for listing in l.listing:
117+
if listing.hidden:
118+
l.listing.remove(listing)
116119
return [l.SerializeToString(), self.signing_key.sign(l.SerializeToString())[:64]]
117120
except Exception:
118121
self.log.warning("could not find any listings in the database")

protos/objects.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ message Listings {
124124
ContractType contract_type = 12;
125125
uint64 last_modified = 13;
126126
bool pinned = 14;
127+
bool hidden = 15;
127128
}
128129

129130
enum ContractType {

protos/objects.py

Lines changed: 26 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)