Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix client ip #85

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wtnt/team/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Meta:
]

def get_image_url(self, obj):
return obj.image + "image.jpg"
return obj.image + "/image.jpg"

from rest_framework.fields import empty

Expand Down
7 changes: 6 additions & 1 deletion wtnt/team/team/service.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.core.cache import cache

import wtnt.settings as api_settings
import core.exception.team as team_exception
import core.exception.notfound as notfound_exception
from core.pagenations import TeamPagination
Expand Down Expand Up @@ -78,8 +79,12 @@ def get_team_detail(self):
cache_key = f"team_detail_{team_id}"

team = cache.get(cache_key)
if api_settings.DEBUG:
user_ip = self.request.META.get("REMOTE_ADDR")
else:
user_ip = self.request.META.get("HTTP_X_REAL_IP")

redis_ans = RedisUtils.sadd_view_client(team_id, user_id, self.request.META.get("REMOTE_ADDR"))
redis_ans = RedisUtils.sadd_view_client(team_id, user_id, user_ip)

if team is None:
team = self.get_team_data_from_id(team_id)
Expand Down