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

Commit 1f8cc05

Browse files
committed
Add moderator list to profile
1 parent 41c9fa5 commit 1f8cc05

4 files changed

Lines changed: 86 additions & 73 deletions

File tree

api/restapi.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def parse_profile(profile):
9999
"nsfw": profile.nsfw,
100100
"vendor": profile.vendor,
101101
"moderator": profile.moderator,
102+
"moderator_list": profile.moderator_list,
102103
"handle": profile.handle,
103104
"about": profile.about,
104105
"website": profile.website,
@@ -320,6 +321,9 @@ def update_profile(self, request):
320321
u.vendor = str_to_bool(request.args["vendor"][0])
321322
if "moderator" in request.args:
322323
u.moderator = str_to_bool(request.args["moderator"][0])
324+
if "moderator_list" in request.args:
325+
for moderator in request.args["moderator_list"]:
326+
u.moderator_list.append(moderator)
323327
if "website" in request.args:
324328
u.website = request.args["website"][0]
325329
if "email" in request.args:
@@ -358,7 +362,7 @@ def add_social_account(self, request):
358362
p = Profile(self.db)
359363
if "account_type" in request.args and "username" in request.args and "proof" in request.args:
360364
p.add_social_account(request.args["account_type"][0], request.args["username"][0],
361-
request.args["proof"][0])
365+
request.args["proof"][0] if "proof" in request.args else None)
362366
else:
363367
raise Exception("Missing required fields")
364368
request.write(json.dumps({"success": True}))

market/profile.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ def update(self, user_info):
3535
self.profile.MergeFrom(user_info)
3636
self.db.set_proto(self.profile.SerializeToString())
3737

38-
def add_social_account(self, account_type, username, proof):
38+
def add_social_account(self, account_type, username, proof=None):
3939
s = self.profile.SocialAccount()
4040
for social_account in self.profile.social:
4141
if social_account.type == s.SocialType.Value(account_type.upper()):
4242
self.profile.social.remove(social_account)
4343
s.type = s.SocialType.Value(account_type.upper())
4444
s.username = username
45-
s.proof_url = proof
45+
if proof:
46+
s.proof_url = proof
4647
self.profile.social.extend([s])
4748
self.db.set_proto(self.profile.SerializeToString())
4849

protos/objects.proto

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,28 @@ message Profile {
3535
optional bool nsfw = 5 [default = false];
3636
optional bool vendor = 6 [default = false];
3737
optional bool moderator = 7 [default = false];
38-
optional string handle = 8;
39-
optional string about = 9;
40-
optional string short_description = 10;
41-
optional string website = 11;
42-
optional string email = 12;
43-
repeated SocialAccount social = 13;
44-
optional uint32 primary_color = 14 [default = 4868168];
45-
optional uint32 secondary_color = 15 [default = 5723734];
46-
optional uint32 background_color = 16 [default = 2763306];
47-
optional uint32 text_color = 17 [default = 16777215];
48-
optional uint32 follower_count = 18 [default = 0];
49-
optional uint32 following_count = 19 [default = 0];
50-
optional PublicKey pgp_key = 20; // pgp signature covers guid
51-
optional bytes avatar_hash = 21;
52-
optional bytes header_hash = 22;
38+
repeated bytes moderator_list = 8;
39+
optional string handle = 9;
40+
optional string about = 10;
41+
optional string short_description = 11;
42+
optional string website = 12;
43+
optional string email = 13;
44+
repeated SocialAccount social = 14;
45+
optional uint32 primary_color = 15 [default = 4868168];
46+
optional uint32 secondary_color = 16 [default = 5723734];
47+
optional uint32 background_color = 17 [default = 2763306];
48+
optional uint32 text_color = 18 [default = 16777215];
49+
optional uint32 follower_count = 19 [default = 0];
50+
optional uint32 following_count = 20 [default = 0];
51+
optional PublicKey pgp_key = 21; // pgp signature covers guid
52+
optional bytes avatar_hash = 22;
53+
optional bytes header_hash = 23;
5354

5455
// Social media account for the profile
5556
message SocialAccount {
5657
required SocialType type = 1;
5758
required string username = 2;
58-
required string proof_url = 3;
59+
optional string proof_url = 3;
5960

6061
enum SocialType {
6162
FACEBOOK = 1;

0 commit comments

Comments
 (0)