forked from zoffline/zwift-offline
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'zoffline:master' into master
- Loading branch information
Showing
12 changed files
with
155 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<Zwift version="1.0.135346" sversion="1.74.2 (135346)" gbranch="rc/1.74.2" gcommit="cee9bc1a0695188de219a22cd80558aa1305ad14" GAME_URL="https://us-or-rly101.zwift.com" manifest="ZwiftMac_1.0.135346_5ea34d1d_manifest.xml" manifest_checksum="-152007760" ver_cur_checksum="1636541751"/> | ||
<Zwift version="1.0.135522" sversion="1.75.0 (135522)" gbranch="rc/1.75.0" gcommit="8ae443ecd463479b622a0dd567a12fc63e1364fe" GAME_URL="https://us-or-rly101.zwift.com" manifest="ZwiftMac_1.0.135522_0b195230_manifest.xml" manifest_checksum="26082961" ver_cur_checksum="-1668066900"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<Zwift version="1.0.135346" sversion="1.74.2 (135346)" gbranch="rc/1.74.2" gcommit="cee9bc1a0695188de219a22cd80558aa1305ad14" GAME_URL="https://us-or-rly101.zwift.com" manifest="Zwift_1.0.135346_5ea34d1d_manifest.xml" manifest_checksum="-798143194" ver_cur_checksum="-866057058"/> | ||
<Zwift version="1.0.135522" sversion="1.75.0 (135522)" gbranch="rc/1.75.0" gcommit="8ae443ecd463479b622a0dd567a12fc63e1364fe" GAME_URL="https://us-or-rly101.zwift.com" manifest="Zwift_1.0.135522_0b195230_manifest.xml" manifest_checksum="-1024030966" ver_cur_checksum="392804262"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1743,29 +1743,14 @@ def bikeFrameToStr(val): | |
return GD['bikeframes'][val] | ||
return "---" | ||
|
||
def do_api_profiles(profile_id, is_json): | ||
profile = profile_pb2.PlayerProfile() | ||
profile_file = '%s/%s/profile.bin' % (STORAGE_DIR, profile_id) | ||
if not os.path.isfile(profile_file): | ||
profile.id = profile_id | ||
profile.email = current_user.username | ||
profile.first_name = current_user.first_name | ||
profile.last_name = current_user.last_name | ||
else: | ||
with open(profile_file, 'rb') as fd: | ||
profile.ParseFromString(fd.read()) | ||
profile.id = profile_id | ||
if not profile.email: | ||
profile.email = '[email protected]' | ||
for entitlement in list(profile.entitlements): | ||
if entitlement.type == profile_pb2.ProfileEntitlement.EntitlementType.RIDE: | ||
profile.entitlements.remove(entitlement) | ||
e = profile.entitlements.add() | ||
e.type = profile_pb2.ProfileEntitlement.EntitlementType.RIDE | ||
e.id = -1 | ||
e.status = profile_pb2.ProfileEntitlement.ProfileEntitlementStatus.ACTIVE | ||
if not profile.mix_panel_distinct_id: | ||
profile.mix_panel_distinct_id = str(uuid.uuid4()) | ||
def update_entitlements(profile): | ||
for entitlement in list(profile.entitlements): | ||
if entitlement.type == profile_pb2.ProfileEntitlement.EntitlementType.RIDE: | ||
profile.entitlements.remove(entitlement) | ||
e = profile.entitlements.add() | ||
e.type = profile_pb2.ProfileEntitlement.EntitlementType.RIDE | ||
e.id = -1 | ||
e.status = profile_pb2.ProfileEntitlement.ProfileEntitlementStatus.ACTIVE | ||
if os.path.isfile('%s/unlock_entitlements.txt' % STORAGE_DIR) or os.path.isfile('%s/unlock_all_equipment.txt' % STORAGE_DIR): | ||
with open('%s/data/entitlements.txt' % SCRIPT_DIR) as f: | ||
entitlements = json.load(f) | ||
|
@@ -1778,6 +1763,19 @@ def do_api_profiles(profile_id, is_json): | |
e.type = profile_pb2.ProfileEntitlement.EntitlementType.USE | ||
e.id = entitlement['id'] | ||
e.status = profile_pb2.ProfileEntitlement.ProfileEntitlementStatus.ACTIVE | ||
|
||
def do_api_profiles(profile_id, is_json): | ||
profile = profile_pb2.PlayerProfile() | ||
profile_file = '%s/%s/profile.bin' % (STORAGE_DIR, profile_id) | ||
if os.path.isfile(profile_file): | ||
with open(profile_file, 'rb') as fd: | ||
profile.ParseFromString(fd.read()) | ||
else: | ||
profile.email = current_user.username | ||
profile.first_name = current_user.first_name | ||
profile.last_name = current_user.last_name | ||
profile.mix_panel_distinct_id = str(uuid.uuid4()) | ||
profile.id = profile_id | ||
if is_json: #todo: publicId, bodyType, totalRunCalories != total_watt_hours, totalRunTimeInMinutes != time_ridden_in_minutes etc | ||
if profile.dob != "": | ||
profile.age = age(datetime.datetime.strptime(profile.dob, "%m/%d/%Y")) | ||
|
@@ -1800,6 +1798,7 @@ def do_api_profiles(profile_id, is_json): | |
copyAttributes(jprofile, jprofileFull, 'privateAttributes') | ||
return jsonify(jprofile) | ||
else: | ||
update_entitlements(profile) | ||
return profile.SerializeToString(), 200 | ||
|
||
@app.route('/api/profiles/me', methods=['GET'], strict_slashes=False) | ||
|
@@ -1811,6 +1810,20 @@ def api_profiles_me(): | |
else: | ||
return do_api_profiles(current_user.player_id, False) | ||
|
||
@app.route('/api/profiles/me/entitlements', methods=['GET']) | ||
@jwt_to_session_cookie | ||
@login_required | ||
def api_profiles_me_entitlements(): | ||
profile = profile_pb2.PlayerProfile() | ||
profile_file = '%s/%s/profile.bin' % (STORAGE_DIR, current_user.player_id) | ||
if os.path.isfile(profile_file): | ||
with open(profile_file, 'rb') as fd: | ||
profile.ParseFromString(fd.read()) | ||
update_entitlements(profile) | ||
entitlements = profile_pb2.ProfileEntitlements() | ||
entitlements.entitlements.extend(profile.entitlements) | ||
return entitlements.SerializeToString(), 200 | ||
|
||
@app.route('/api/profiles/<int:profile_id>', methods=['GET']) | ||
@jwt_to_session_cookie | ||
@login_required | ||
|