Skip to content

Commit

Permalink
Improving Lemmy 0.18.0 support (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
fishcharlie authored Jul 3, 2023
1 parent a8c8ceb commit 3a5c175
Show file tree
Hide file tree
Showing 36 changed files with 127 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ public enum ListingType: String, Codable, CustomStringConvertible, CaseIterable
case all = "All"
case local = "Local"
case subscribed = "Subscribed"
case community = "Community"

public var description: String {
return rawValue
Expand Down
22 changes: 14 additions & 8 deletions Sources/Lemmy-Swift-Client/Lemmy API/Enums/SortType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,30 @@ public enum SortType: String, Codable, CustomStringConvertible, CaseIterable {
case active = "Active"
/// Posts sorted by a decaying rank.
case hot = "Hot"
/// Posts sorted by the most comments.
case mostComments = "MostComments"
/// Posts sorted by the published time.
case new = "New"
/// Posts sorted by the newest comments, with no necrobumping. IE a forum sort.
case newComments = "NewComments"
/// Posts sorted by the published time ascending
case old = "Old"
/// The top posts of all time.
case topAll = "TopAll"
/// The top posts for this last day.
case topDay = "TopDay"
/// The top posts for this last month.
case topMonth = "TopMonth"
/// The top posts for this last week.
case topWeek = "TopWeek"
/// The top posts for this last month.
case topMonth = "TopMonth"
/// The top posts for this last year.
case topYear = "TopYear"
/// The top posts of all time.
case topAll = "TopAll"
/// Posts sorted by the most comments.
case mostComments = "MostComments"
/// Posts sorted by the newest comments, with no necrobumping. IE a forum sort.
case newComments = "NewComments"
/// The top posts for this last hour.
case topHour = "TopHour"
/// The top posts for this last six hour.
case topSixHour = "TopSixHour"
/// The top posts for this last six hour.
case topTwelveHour = "TopTwelveHour"

public var description: String {
return rawValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public struct SaveUserSettingsRequest: APIRequest {
public let banner: String?
public let bio: String?
public let bot_account: Bool?
public let default_listing_type: Int?
public let default_sort_type: Int?
public let default_listing_type: ListingType?
public let default_sort_type: SortType?
public let discussion_languages: [Int]?
public let display_name: String?
public let email: String?
Expand All @@ -33,8 +33,8 @@ public struct SaveUserSettingsRequest: APIRequest {
banner: String? = nil,
bio: String? = nil,
bot_account: Bool? = nil,
default_listing_type: Int? = nil,
default_sort_type: Int? = nil,
default_listing_type: ListingType? = nil,
default_sort_type: SortType? = nil,
discussion_languages: [Int]? = nil,
display_name: String? = nil,
email: String? = nil,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Foundation

public struct AdminPurgeCommentView: Codable {
public let admin: PersonSafe?
public let admin: Person?
public let admin_purge_comment: AdminPurgeComment
public let post: Post

public init(admin: PersonSafe? = nil, admin_purge_comment: AdminPurgeComment, post: Post) {
public init(admin: Person? = nil, admin_purge_comment: AdminPurgeComment, post: Post) {
self.admin = admin
self.admin_purge_comment = admin_purge_comment
self.post = post
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Foundation

public struct AdminPurgeCommunityView: Codable {
public let admin: PersonSafe?
public let admin: Person?
public let admin_purge_community: AdminPurgeCommunity

public init(admin: PersonSafe? = nil, admin_purge_community: AdminPurgeCommunity) {
public init(admin: Person? = nil, admin_purge_community: AdminPurgeCommunity) {
self.admin = admin
self.admin_purge_community = admin_purge_community
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Foundation

public struct AdminPurgePersonView: Codable {
public let admin: PersonSafe?
public let admin: Person?
public let admin_purge_person: AdminPurgePerson

public init(admin: PersonSafe? = nil, admin_purge_person: AdminPurgePerson) {
public init(admin: Person? = nil, admin_purge_person: AdminPurgePerson) {
self.admin = admin
self.admin_purge_person = admin_purge_person
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Foundation

public struct AdminPurgePostView: Codable {
public let admin: PersonSafe?
public let admin: Person?
public let admin_purge_post: AdminPurgePost
public let community: CommunitySafe

public init(admin: PersonSafe? = nil, admin_purge_post: AdminPurgePost, community: CommunitySafe) {
public init(admin: Person? = nil, admin_purge_post: AdminPurgePost, community: CommunitySafe) {
self.admin = admin
self.admin_purge_post = admin_purge_post
self.community = community
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ public struct CommentReplyView: Codable {
public let comment_reply: CommentReply
public let community: CommunitySafe
public let counts: CommentAggregates
public let creator: PersonSafe
public let creator: Person
public let creator_banned_from_community: Bool
public let creator_blocked: Bool
public let my_vote: Int?
public let post: Post
public let recipient: PersonSafe
public let recipient: Person
public let saved: Bool
public let subscribed: SubscribedType

Expand All @@ -19,12 +19,12 @@ public struct CommentReplyView: Codable {
comment_reply: CommentReply,
community: CommunitySafe,
counts: CommentAggregates,
creator: PersonSafe,
creator: Person,
creator_banned_from_community: Bool,
creator_blocked: Bool,
my_vote: Int? = nil,
post: Post,
recipient: PersonSafe,
recipient: Person,
saved: Bool,
subscribed: SubscribedType
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ import Foundation

public struct CommentReportView: Codable {
public let comment: Comment
public let comment_creator: PersonSafe
public let comment_creator: Person
public let comment_report: CommentReport
public let community: CommunitySafe
public let counts: CommentAggregates
public let creator: PersonSafe
public let creator: Person
public let creator_banned_from_community: Bool
public let my_vote: Int?
public let post: Post
public let resolver: PersonSafe?
public let resolver: Person?

public init(
comment: Comment,
comment_creator: PersonSafe,
comment_creator: Person,
comment_report: CommentReport,
community: CommunitySafe,
counts: CommentAggregates,
creator: PersonSafe,
creator: Person,
creator_banned_from_community: Bool,
my_vote: Int? = nil,
post: Post,
resolver: PersonSafe? = nil
resolver: Person? = nil
) {
self.comment = comment
self.comment_creator = comment_creator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public struct CommentView: Codable {
public let comment: Comment
public let community: CommunitySafe
public let counts: CommentAggregates
public let creator: PersonSafe
public let creator: Person
public let creator_banned_from_community: Bool
public let creator_blocked: Bool
public let my_vote: Int?
Expand All @@ -16,7 +16,7 @@ public struct CommentView: Codable {
comment: Comment,
community: CommunitySafe,
counts: CommentAggregates,
creator: PersonSafe,
creator: Person,
creator_banned_from_community: Bool,
creator_blocked: Bool,
my_vote: Int? = nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import Foundation

public struct CommunityBlockView: Codable {
public let community: CommunitySafe
public let person: PersonSafe
public let person: Person

public init(community: CommunitySafe, person: PersonSafe) {
public init(community: CommunitySafe, person: Person) {
self.community = community
self.person = person
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import Foundation

public struct CommunityFolowerView: Codable {
public let community: CommunitySafe
public let follower: PersonSafe
public let follower: Person

public init(community: CommunitySafe, follower: PersonSafe) {
public init(community: CommunitySafe, follower: Person) {
self.community = community
self.follower = follower
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import Foundation

public struct CommunityModeratorView: Codable {
public let community: CommunitySafe
public let moderator: PersonSafe
public let moderator: Person

public init(community: CommunitySafe, moderator: PersonSafe) {
public init(community: CommunitySafe, moderator: Person) {
self.community = community
self.moderator = moderator
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Foundation

public struct LocalUserSettings: Codable {
public struct LocalUser: Codable {
public let accepted_application: Bool
public let default_listing_type: Int
public let default_sort_type: Int
public let default_listing_type: ListingType
public let default_sort_type: SortType
public let email: String?
public let email_verified: Bool
public let id: Int
Expand All @@ -21,8 +21,8 @@ public struct LocalUserSettings: Codable {

public init(
accepted_application: Bool,
default_listing_type: Int,
default_sort_type: Int,
default_listing_type: ListingType,
default_sort_type: SortType,
email: String? = nil,
email_verified: Bool,
id: Int,
Expand Down

This file was deleted.

13 changes: 13 additions & 0 deletions Sources/Lemmy-Swift-Client/Lemmy API/Structs/LocalUserView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Foundation

public struct LocalUserView: Codable {
public let counts: PersonAggregates
public let local_user: LocalUser
public let person: Person

public init(counts: PersonAggregates, local_user: LocalUser, person: Person) {
self.counts = counts
self.local_user = local_user
self.person = person
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import Foundation
public struct ModAddCommunityView: Codable {
public let community: CommunitySafe
public let mod_add_community: ModAddCommunity
public let modded_person: PersonSafe
public let moderator: PersonSafe
public let modded_person: Person
public let moderator: Person

public init(
community: CommunitySafe,
mod_add_community: ModAddCommunity,
modded_person: PersonSafe,
moderator: PersonSafe
modded_person: Person,
moderator: Person
) {
self.community = community
self.mod_add_community = mod_add_community
Expand Down
6 changes: 3 additions & 3 deletions Sources/Lemmy-Swift-Client/Lemmy API/Structs/ModAddView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import Foundation

public struct ModAddView: Codable {
public let mod_add: ModAdd
public let modded_person: PersonSafe
public let moderator: PersonSafe?
public let modded_person: Person
public let moderator: Person?

public init(mod_add: ModAdd, modded_person: PersonSafe, moderator: PersonSafe? = nil) {
public init(mod_add: ModAdd, modded_person: Person, moderator: Person? = nil) {
self.mod_add = mod_add
self.modded_person = modded_person
self.moderator = moderator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import Foundation

public struct ModBanFromCommunityView: Codable {
public let banned_person: PersonSafe
public let banned_person: Person
public let community: CommunitySafe
public let mod_ban_from_community: ModBanFromCommunity
public let moderator: PersonSafe?
public let moderator: Person?

public init(
banned_person: PersonSafe,
banned_person: Person,
community: CommunitySafe,
mod_ban_from_community: ModBanFromCommunity,
moderator: PersonSafe? = nil
moderator: Person? = nil
) {
self.banned_person = banned_person
self.community = community
Expand Down
6 changes: 3 additions & 3 deletions Sources/Lemmy-Swift-Client/Lemmy API/Structs/ModBanView.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Foundation

public struct ModBanView: Codable {
public let banned_person: PersonSafe
public let banned_person: Person
public let mod_ban: ModBan
public let moderator: PersonSafe?
public let moderator: Person?

public init(banned_person: PersonSafe, mod_ban: ModBan, moderator: PersonSafe? = nil) {
public init(banned_person: Person, mod_ban: ModBan, moderator: Person? = nil) {
self.banned_person = banned_person
self.mod_ban = mod_ban
self.moderator = moderator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import Foundation
public struct ModFeaturePostView: Codable {
public let community: CommunitySafe
public let mod_feature_post: ModFeaturePost
public let moderator: PersonSafe?
public let moderator: Person?
public let post: Post

public init(
community: CommunitySafe,
mod_feature_post: ModFeaturePost,
moderator: PersonSafe? = nil,
moderator: Person? = nil,
post: Post
) {
self.community = community
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import Foundation
public struct ModLockPostView: Codable {
public let community: CommunitySafe
public let mod_lock_post: ModLockPost
public let moderator: PersonSafe?
public let moderator: Person?
public let post: Post

public init(
community: CommunitySafe,
mod_lock_post: ModLockPost,
moderator: PersonSafe? = nil,
moderator: Person? = nil,
post: Post
) {
self.community = community
Expand Down
Loading

0 comments on commit 3a5c175

Please sign in to comment.