Skip to content

Commit

Permalink
Merge pull request #4389 from hotosm/develop
Browse files Browse the repository at this point in the history
v4.4.2
  • Loading branch information
willemarcel authored Mar 17, 2021
2 parents ba2def2 + e4e1da7 commit 8372c16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions backend/services/messaging/message_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def send_message_after_comment(
messages = []
for user_id in contributed_users:
try:
user = UserService.get_user_dto_by_id(user_id)
user = UserService.get_user_by_id(user_id)
# if user was mentioned, a message has already been sent to them,
# so we can skip
if user.username in usernames:
Expand Down Expand Up @@ -430,7 +430,7 @@ def send_message_after_chat(chat_from: int, chat: str, project_id: int):
messages = []
for user_id in users_to_notify:
try:
user = UserService.get_user_dto_by_id(user_id)
user = UserService.get_user_by_id(user_id)
except NotFound:
continue # If we can't find the user, keep going no need to fail
message = Message()
Expand Down Expand Up @@ -468,7 +468,7 @@ def send_favorite_project_activities(user_id: int):
> datetime.date.today() - datetime.timedelta(days=300)
)
)
user = UserService.get_user_dto_by_id(user_id)
user = UserService.get_user_by_id(user_id)
messages = []
for project in recently_updated_projects:
activity_message = []
Expand Down
11 changes: 6 additions & 5 deletions backend/services/users/user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,13 @@ def get_user_dto_by_username(
return requested_user.as_dto(logged_in_user.username)

@staticmethod
def get_user_dto_by_id(requested_user: int, logged_in_user: int) -> UserDTO:
def get_user_dto_by_id(user: int, request_user: int) -> UserDTO:
"""Gets user DTO for supplied user id """
requested_user = UserService.get_user_by_id(requested_user)
logged_in_user = UserService.get_user_by_id(logged_in_user)

return requested_user.as_dto(logged_in_user.username)
user = UserService.get_user_by_id(user)
if request_user:
request_username = UserService.get_user_by_id(request_user).username
return user.as_dto(request_username)
return user.as_dto()

@staticmethod
def get_interests_stats(user_id):
Expand Down

0 comments on commit 8372c16

Please sign in to comment.