Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: appengine/monorail/proto/user_pb2.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/monorail/proto/tracker_pb2.py ('k') | appengine/monorail/proto/usergroup_pb2.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is govered by a BSD-style
3 # license that can be found in the LICENSE file or at
4 # https://developers.google.com/open-source/licenses/bsd
5
6 """Protocol buffers for Monorail users."""
7
8 from protorpc import messages
9
10
11 class ActionLimit(messages.Message):
12 """In-memory business object for action rate limiting.
13
14 We will keep track of the number of actions
15 of various types by individual users and limit each user's ability
16 to perform a large number of those actions. E.g., no one user can
17 create too many new projects.
18
19 Our application code checks three kinds of action limits:
20 1. A soft limit on the number of actions in a period of time.
21 If this soft limit is exceeded, the user will need to solve a CAPTCHA.
22 2. A hard limit on the number of actions in a period of time.
23 if this hard limit is exceeded, the requested actions will fail.
24 3. A lifetime limit. The user cannot perform this type of action more
25 than this many times, ever. We can adjust the lifetime limit
26 for individual users who contact us.
27
28 The numeric values for the actual limits are coded as constants in our
29 application. Only the lifetime limit is stored in this PB, and then only
30 if it differs from the default.
31 """
32 # Number of times that the user has performed this type of action recently.
33 recent_count = messages.IntegerField(1, required=True, default=0)
34
35 # Time of most recent counter reset in seconds.
36 # If (Now - reset_timestamp) > threshold, recent_count may be zeroed.
37 reset_timestamp = messages.IntegerField(2, required=True, default=0)
38
39 # Number of times that the user has performed this type of action ever.
40 lifetime_count = messages.IntegerField(3, required=True, default=0)
41
42 # This field is only present for users who have contacted us and
43 # asked us to increase their lifetime limit. When present, this value
44 # overrides the application's built-in default limit.
45 lifetime_limit = messages.IntegerField(4, default=0)
46
47 # This field is only present for users who have contacted us and
48 # asked us to increase their period limit. When present, this value
49 # overrides the application's built-in default limit.
50 period_soft_limit = messages.IntegerField(5, default=0)
51 period_hard_limit = messages.IntegerField(6, default=0)
52
53
54 class IssueUpdateNav(messages.Enum):
55 """Pref for where a project member goes after an issue update."""
56 UP_TO_LIST = 0 # Back to issue list or grid view.
57 STAY_SAME_ISSUE = 1 # Show the same issue with the update.
58 NEXT_IN_LIST = 2 # Triage mode: go to next issue, if any.
59
60
61 class User(messages.Message):
62 """In-memory busines object for representing users."""
63 # Is this user a site administer?
64 is_site_admin = messages.BooleanField(4, required=True, default=False)
65
66 # User notification preferences. These preferences describe when
67 # a user is sent a email notification after an issue has changed.
68 # The user is notified if either of the following is true:
69 # 1. notify_issue_change is True and the user is named in the
70 # issue's Owner or CC field.
71 # 2. notify_starred_issue_change is True and the user has starred
72 # the issue.
73 notify_issue_change = messages.BooleanField(5, default=True)
74 notify_starred_issue_change = messages.BooleanField(6, default=True)
75
76 # This user has been banned, and this string describes why. All access
77 # to Monorail pages should be disabled.
78 banned = messages.StringField(7, default='')
79
80 # User action counts and limits.
81 project_creation_limit = messages.MessageField(ActionLimit, 8)
82 issue_comment_limit = messages.MessageField(ActionLimit, 9)
83 issue_attachment_limit = messages.MessageField(ActionLimit, 10)
84 issue_bulk_edit_limit = messages.MessageField(ActionLimit, 11)
85 ignore_action_limits = messages.BooleanField(13, default=False)
86
87 after_issue_update = messages.EnumField(
88 IssueUpdateNav, 29, default=IssueUpdateNav.STAY_SAME_ISSUE)
89
90 # Should we obfuscate the user's email address and require solving a captcha
91 # to reveal it entirely? The default value corresponds to requiring users to
92 # opt into publishing their identities, but our code ensures that the
93 # opposite takes place for Gmail accounts.
94 obscure_email = messages.BooleanField(26, default=True)
95
96 # The email address chosen by the user to reveal on the site.
97 email = messages.StringField(27)
98
99 # The user has seen these cue cards and dismissed them.
100 dismissed_cues = messages.StringField(32, repeated=True)
101
102 # Sticky state for show/hide widget on people details page.
103 keep_people_perms_open = messages.BooleanField(33, default=False)
104
105 deleted = messages.BooleanField(39, default=False)
106 deleted_timestamp = messages.IntegerField(40, default=0)
107
108 preview_on_hover = messages.BooleanField(42, default=True)
109
110 flag_spam_limit = messages.MessageField(ActionLimit, 43)
111 api_request_limit = messages.MessageField(ActionLimit, 44)
112
113 def MakeUser():
114 """Create and return a new user record in RAM."""
115 user = User()
116 user.project_creation_limit = ActionLimit()
117 user.issue_comment_limit = ActionLimit()
118 user.issue_attachment_limit = ActionLimit()
119 user.issue_bulk_edit_limit = ActionLimit()
120 user.flag_spam_limit = ActionLimit()
121 user.api_request_limit = ActionLimit()
122 return user
OLDNEW
« no previous file with comments | « appengine/monorail/proto/tracker_pb2.py ('k') | appengine/monorail/proto/usergroup_pb2.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698