Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request #44 from jimmya/master
Browse files Browse the repository at this point in the history
Updated to Vapor 2.0, restructured and cleaned up code in some places.
  • Loading branch information
Matthijs Logemann authored Jun 2, 2017
2 parents 6326d91 + a9c9091 commit 51d85d2
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 340 deletions.
22 changes: 13 additions & 9 deletions .ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,37 @@ then
wget https://swift.org/builds/swift-$VERSION-release/$OS/swift-$VERSION-RELEASE/$SWIFTFILE.tar.gz
tar -zxf $SWIFTFILE.tar.gz
export PATH=$PWD/$SWIFTFILE/usr/bin:"${PATH}"
else
echo "📚 Installing Dependencies"
brew tap vapor/homebrew-tap
brew install ctls
fi

echo "📅 Version: `swift --version`";

echo "🚀 Building";
swift build
if [[ $? != 0 ]];
then
if [[ $? != 0 ]];
then
echo "❌ Build failed";
exit 1;
exit 1;
fi

echo "💼 Building Release";
swift build -c release
if [[ $? != 0 ]];
then
if [[ $? != 0 ]];
then
echo "❌ Build for release failed";
exit 1;
exit 1;
fi

echo "🔎 Testing";

swift test
if [[ $? != 0 ]];
then
if [[ $? != 0 ]];
then
echo "❌ Tests failed";
exit 1;
exit 1;
fi

echo "✅ Done"
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ let package = Package(
name: "VaporAPNS",
targets: [],
dependencies: [
.Package(url: "https://github.com/vapor/json.git", majorVersion: 1, minor: 0),
.Package(url: "https://github.com/vapor/json.git", majorVersion: 2),
.Package(url: "https://github.com/vapor/clibressl.git", majorVersion: 1),
.Package(url: "https://github.com/vapor/console.git", majorVersion: 1),
.Package(url: "https://github.com/vapor/console.git", majorVersion: 2),
.Package(url: "https://github.com/matthijs2704/SwiftString.git", majorVersion: 1, minor: 0),
.Package(url: "https://github.com/boostcode/CCurl.git", majorVersion: 0, minor: 2),
.Package(url: "https://github.com/vapor/jwt.git", majorVersion: 1)
.Package(url: "https://github.com/vapor/jwt.git", majorVersion: 2)
],
exclude: ["Images"]
)
148 changes: 0 additions & 148 deletions Sources/VaporAPNS/Jay+Utils.swift

This file was deleted.

38 changes: 16 additions & 22 deletions Sources/VaporAPNS/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,44 +96,38 @@ public struct Options: CustomStringConvertible, NodeInitializable {
}


public init(node: Node, in context: Context) throws {
if let topic = node["topic"]?.string {
self.topic = topic
}else {
public init(node: Node) throws {
guard let topic = node["topic"]?.string else {
throw InitializeError.noTopic
}
self.topic = topic

if let portRaw = node["port"]?.int, let port = Port(rawValue: portRaw) {
self.port = port
}

var hasAnyAuthentication = false
var hasBothAuthentication = false

if let certPath = node["certificatePath"]?.string, let keyPath = node["keyPath"]?.string {
hasAnyAuthentication = true
self.certPath = certPath
self.keyPath = keyPath

}
var hasAuthentication = false

if let privateKeyLocation = node["keyPath"]?.string, let keyId = node["keyId"]?.string {
if hasAnyAuthentication { hasBothAuthentication = true }
hasAnyAuthentication = true
hasAuthentication = true
let (priv, pub) = try privateKeyLocation.tokenString()
self.privateKey = priv
self.publicKey = pub
self.keyId = keyId
}

guard hasAnyAuthentication else {
throw InitializeError.noAuthentication

if let certPath = node["certificatePath"]?.string, let keyPath = node["keyPath"]?.string {
if hasAuthentication {
print ("You've seem to have specified both authentication methods, choosing preferred APNS Auth Key method...")
} else {
hasAuthentication = true
self.certPath = certPath
self.keyPath = keyPath
}
}

if hasBothAuthentication {
print ("You've seem to have specified both authentication methods, choosing preferred APNS Auth Key method...")
certPath = nil
keyPath = nil
guard hasAuthentication else {
throw InitializeError.noAuthentication
}
}

Expand Down
Loading

0 comments on commit 51d85d2

Please sign in to comment.