Browse Source

Fix build

master
parent
commit
1fde205cb3
Signed by: StDingenskirchen GPG Key ID: 14FE9712CC42FE8B
3 changed files with 14 additions and 5 deletions
  1. +10
    -1
      default.nix
  2. +1
    -1
      src/responses/api/json/resolve.cr
  3. +3
    -3
      src/shashort.cr

+ 10
- 1
default.nix View File

@ -1,4 +1,12 @@
with import <nixpkgs> {};
with import (builtins.fetchTarball {
# nixpkgs master on 2020-10-14
url =
"https://github.com/NixOS/nixpkgs/tarball/d5291756487d70bc336e33512a9baf9fa1788faf";
sha256 = "0mhqhq21y5vrr1f30qd2bvydv4bbbslvyzclhw0kdxmkgg3z4c92";
}) { };
crystal.buildCrystalPackage rec {
version = "0.1.0";
pname = "SHAShort";
@ -6,6 +14,7 @@ crystal.buildCrystalPackage rec {
shardsFile = ./shards.nix;
crystalBinaries.SHAShort.src = "src/shashort.cr";
format = "crystal";
buildInputs = [ sqlite-interactive.dev ];
}

+ 1
- 1
src/responses/api/json/resolve.cr View File

@ -2,7 +2,7 @@ require "../../../logic"
get "/api/v1/resolve" do |env|
env.response.content_type = "application/json"
hash = URI.unescape(env.params.query["hash"])
hash = URI.decode(env.params.query["hash"])
hash = hash.lchop("https://ding.15318.de/resolve/").strip
begin
url = SHAShortLogic.fetch_link(hash)


+ 3
- 3
src/shashort.cr View File

@ -6,15 +6,15 @@ require "dotenv"
module SHAShort
extend self
@@last_hash_time = Time.unix(0)
@@last_hash_time = Time.utc
RATELIMIT = Time::Span.new(0, 0, 1)
def ratelimited?
Time.now - @@last_hash_time < RATELIMIT
Time.utc - @@last_hash_time < RATELIMIT
end
def ratelimit_set_now
@@last_hash_time = Time.now
@@last_hash_time = Time.utc
end
end


Loading…
Cancel
Save