-
-
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.
Store skins to better understand what goes wrong
- Loading branch information
Showing
6 changed files
with
66 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defmodule GlobalApi.Schema.SkinStorage do | ||
use Ecto.Schema | ||
|
||
schema "skin_storage" do | ||
field :hash, :binary | ||
field :skin, :string | ||
field :code, :integer | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
defmodule GlobalApi.Skins.SkinStorage do | ||
alias GlobalApi.DatabaseQueue | ||
alias GlobalApi.Repo | ||
alias GlobalApi.Schema.SkinStorage, as: Schema | ||
|
||
def store(client_data, convert_code) do | ||
# Keep: SkinImageHeight, SkinImageWidth, SkinResourcePatch, SkinGeometryDataEngineVersion, SkinGeometryData, SkinData, SkinAnimationData, | ||
# PremiumSkin, PersonaSkin, CapeOnClassicSkin, CapeImageWidth, CapeImageHeight, CapeData, ArmSize, AnimatedImageData. | ||
# The other keys will only result in storing duplicate data | ||
final_data = | ||
client_data | ||
|> Jason.decode!() | ||
|> Map.drop([ | ||
:CapeId, | ||
:ClientRandomId, | ||
:CurrentInputMode, | ||
:DefaultInputMode, | ||
:DeviceId, | ||
:DeviceModel, | ||
:DeviceOS, | ||
:GameVersion, | ||
:GuiScale, | ||
:IsEditorMode, | ||
:LanguageCode, | ||
:PersonaPieces, | ||
:PieceTintColors, | ||
:PlatformOfflineId, | ||
:PlatformOnlineId, | ||
:PlayFabId, | ||
:SelfSignedId, | ||
:ServerAddress, | ||
:SkinColor, | ||
:SkinId, | ||
:ThirdPartyName, | ||
:ThirdPartyNameOnly, | ||
:UIProfile | ||
]) | ||
|> Jason.encode!() | ||
|
||
identifier = Blake2.hash2b(final_data, 32) | ||
|
||
DatabaseQueue.async_fn_call(fn -> | ||
Repo.insert(%Schema{hash: identifier, skin: final_data, code: convert_code}, on_conflict: :nothing) | ||
end) | ||
end | ||
end |
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