Skip to content

Commit

Permalink
Merge pull request #6 from aphung/bugfix_1.2
Browse files Browse the repository at this point in the history
Update 1.2
  • Loading branch information
aphung committed Mar 27, 2024
2 parents 0c47f4a + a737053 commit 49e4f34
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Whereisdi - Domain Invasion Tracker Addon for Windower

**Author:** Kosumi (Asura)<br>
**Version:** 1.1<br>
**Date:** March 26, 2023<br>
**Version:** 1.2<br>
**Date:** March 28, 2024<br>

## Description

Expand Down Expand Up @@ -41,9 +41,9 @@ Windower addon for getting the current location of the Domain Invasion. The data

## Privacy

For the purpose of tracking the Domain Invasion location for each server, this addon sends and receives data to whereisdi which is owned and maintained by the author of this addon.
For the purpose of tracking the Domain Invasion location for each server, this addon sends and receives data to whereisdi.com which is owned and maintained by the author of this addon.

Data is only sent to whereisdi when a unity message is received that corresponds to one of the Unity leaders messages about Domain Invasion. Player names are obfuscated (hashed) and cannot be read by the Author.
Data is only sent to whereisdi when a unity message is received that corresponds to one of the Unity leaders messages about Domain Invasion. Player names are anonymized (hashed) and cannot be read by the author or anyone else.

You can opt out of providing data to whereisdi.com by entering the command `//di send`.

Expand Down
23 changes: 14 additions & 9 deletions api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function M.login(player, server_id, server_name)
local token = sha.sha256(user)
local body = '{"first_name":"Player '..player_hash..'", "server":"'..server_id..'", "email":"'..user..'", "token":"'..token..'", "role":"8a1a1e19-4eb4-4779-8c1a-4024f40ed4b4"}'

post(user_endpoint, token, body)
post(user_endpoint, "", body)
end

function M.get_di_location(server)
Expand Down Expand Up @@ -109,22 +109,27 @@ function get(url)
return code, body
end

function post(url, token, body)
function post(endpoint, token, body)
local response_body = {}

if debug then
log("Body: "..body)
end

endpoint_header = {
["user-agent"] = "whereisdi/".._addon.version,
["content-type"] = "application/json",
["content-length"] = tostring(body:len()),
};

if token ~= nil then
endpoint_header["authorization"] = "Bearer "..token
end

local res, code, response_headers = https.request{
url = location_endpoint;
url = endpoint;
method = "POST";
headers = {
["user-agent"] = "whereisdi/".._addon.version,
["content-type"] = "application/json",
["authorization"] = "Bearer "..token,
["content-length"] = tostring(body:len()),
};
headers = endpoint_header;
source = ltn12.source.string(body);
sink = ltn12.sink.table(response_body);
}
Expand Down

0 comments on commit 49e4f34

Please sign in to comment.