Skip to content

Commit

Permalink
Remove inGroup field
Browse files Browse the repository at this point in the history
  • Loading branch information
ZekeSnider committed Feb 3, 2019
1 parent 099e2f5 commit fca35ca
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 32 deletions.
10 changes: 5 additions & 5 deletions Jared/DatabaseHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class DatabaseHandler {
let handle = String(cString: idcString)
let contact = ContactHelper.RetreiveContact(handle: handle)

People.append(Person(givenName: contact?.givenName, handle: handle, isMe: false, inGroup: nil))
People.append(Person(givenName: contact?.givenName, handle: handle, isMe: false))
}

return Group(name: "", handle: handle, participants: People)
Expand Down Expand Up @@ -186,11 +186,11 @@ class DatabaseHandler {
let group = retrieveGroupInfo(chatID: roomName)

if (isFromMe) {
sender = Person(givenName: myName, handle: destination, isMe: true, inGroup: nil)
recipient = group ?? Person(givenName: buddyName, handle: senderHandle, isMe: false, inGroup: nil)
sender = Person(givenName: myName, handle: destination, isMe: true)
recipient = group ?? Person(givenName: buddyName, handle: senderHandle, isMe: false)
} else {
sender = Person(givenName: buddyName, handle: senderHandle, isMe: false, inGroup: nil)
recipient = group ?? Person(givenName: myName, handle: destination, isMe: true, inGroup: nil)
sender = Person(givenName: buddyName, handle: senderHandle, isMe: false)
recipient = group ?? Person(givenName: myName, handle: destination, isMe: true)
}

let message = Message(body: TextBody(text), date: Date(timeIntervalSince1970: epochDate), sender: sender, recipient: recipient)
Expand Down
19 changes: 1 addition & 18 deletions Jared/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,6 @@ public struct Message: Encodable {
self.date = date
}

// Easily flip a message around to respond to it
init (message: Message, newBody: MessageBody, me: Person) {
body = newBody

let person = message.sender as! Person

// If the person sent in a group,
// we should respond to the group.
if let group = person.inGroup {
recipient = group
} else {
recipient = person
}

sender = me
}

public func RespondTo() -> RecipientEntity {
if let senderPerson = sender as? Person {
if (senderPerson.isMe) {
Expand All @@ -92,7 +75,7 @@ public struct Message: Encodable {
}

NSLog("Couldn't coerce respond to entity properly.")
return Person(givenName: nil, handle: "", isMe: false, inGroup: nil)
return Person(givenName: nil, handle: "", isMe: false)
}

public func getTextBody() -> String? {
Expand Down
4 changes: 1 addition & 3 deletions JaredFramework/Entities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ public struct Person: SenderEntity, RecipientEntity, Codable, Equatable {
public var givenName: String?
public var handle: String
public var isMe: Bool = false
public var inGroup: Group?

public init(givenName: String?, handle: String, isMe: Bool, inGroup: Group?) {
public init(givenName: String?, handle: String, isMe: Bool) {
self.givenName = givenName
self.handle = handle
self.isMe = isMe
self.inGroup = inGroup
}

public static func == (lhs: Person, rhs: Person) -> Bool {
Expand Down
2 changes: 1 addition & 1 deletion JaredFramework/Jared.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

public class Jared {
public static func Send(_ body: String, to recipient: RecipientEntity) {
let me = Person(givenName: nil, handle: "", isMe: true, inGroup: nil)
let me = Person(givenName: nil, handle: "", isMe: true)
let message = Message(body: TextBody(body), date: Date(), sender: me, recipient: recipient)
Send(message, whileBlocking: false)
}
Expand Down
6 changes: 3 additions & 3 deletions JaredTests/MessageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import JaredFramework
class MessageTests: XCTestCase {
let textBody = TextBody("Hey Jared")

let jaredPerson = Person(givenName: "jared", handle: "[email protected]", isMe: false, inGroup: nil)
let mePerson = Person(givenName: "zeke", handle: "[email protected]", isMe: true, inGroup: nil)
let swiftPerson = Person(givenName: "taylor", handle: "[email protected]", isMe: false, inGroup: nil)
let jaredPerson = Person(givenName: "jared", handle: "[email protected]", isMe: false)
let mePerson = Person(givenName: "zeke", handle: "[email protected]", isMe: true)
let swiftPerson = Person(givenName: "taylor", handle: "[email protected]", isMe: false)

var sampleGroup: Group!

Expand Down
2 changes: 1 addition & 1 deletion JaredTests/WebhookTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class WebhookTests: XCTestCase {
let WEBHOOK_TEST_URL = "https://github.com/zekesnider/jaredwebhook"
let WEBHOOK_TEST_URL_TWO = "https://twitter.com/zekesnider/jaredwebhook"
let MESSAGE_SERIALIZED = "{\"body\":{\"message\":\"hello there jared\"},\"recipient\":{\"handle\":\"[email protected]\",\"givenName\":\"jared\",\"isMe\":false},\"sender\":{\"handle\":\"[email protected]\",\"givenName\":\"zeke\",\"isMe\":true},\"date\":\"2017-05-17T22:57:21.000Z\"}"
let SAMPLE_MESSAGE = Message(body: TextBody("hello there jared"), date: Date(timeIntervalSince1970: TimeInterval(1495061841)), sender: Person(givenName: "zeke", handle: "[email protected]", isMe: true, inGroup: nil), recipient: Person(givenName: "jared", handle: "[email protected]", isMe: false, inGroup: nil))
let SAMPLE_MESSAGE = Message(body: TextBody("hello there jared"), date: Date(timeIntervalSince1970: TimeInterval(1495061841)), sender: Person(givenName: "zeke", handle: "[email protected]", isMe: true), recipient: Person(givenName: "jared", handle: "[email protected]", isMe: false))

var config: URLSessionConfiguration!

Expand Down
2 changes: 1 addition & 1 deletion JaredUI/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>286</string>
<string>288</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down

0 comments on commit fca35ca

Please sign in to comment.