Skip to content

Commit 2b09a98

Browse files
committed
[Add] #188 - 디스코드 웹훅 발송을 위한 Endpoint, DTO 추가
1 parent 4c8fd3f commit 2b09a98

2 files changed

Lines changed: 94 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// DiscordWebhookDTO.swift
3+
// Neki-iOS
4+
//
5+
// Created by SwainYun on 3/24/26.
6+
//
7+
8+
import Foundation
9+
10+
public enum DiscordWebhookDTO {
11+
public struct Request: Encodable {
12+
struct Embed: Encodable {
13+
let title: String
14+
let description: String
15+
let color: Int
16+
let fields: [Field]
17+
}
18+
19+
struct Field: Encodable {
20+
let name: String
21+
let value: String
22+
let inline: Bool
23+
}
24+
25+
let embeds: [Embed]
26+
27+
init(unsupportedURL: URL, user: User) {
28+
let host = unsupportedURL.host() ?? "Unknown Host"
29+
let embed = Embed(
30+
title: "🚨 미지원 QR 코드 스캔 감지",
31+
description: "새로운 포토부스 브랜드이거나 파싱에 실패한 URL입니다.",
32+
color: 16711680, // 빨강색 (Hex: FF0000)
33+
fields: [
34+
Field(name: "👤 User", value: "\(user.nickname) (ID: \(user.id))", inline: true),
35+
Field(name: "🌐 Host", value: host, inline: true),
36+
Field(name: "🔗 Full URL", value: unsupportedURL.absoluteString, inline: false)
37+
]
38+
)
39+
40+
self.embeds = [embed]
41+
}
42+
}
43+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// QRCodeScannerEndpoint.swift
3+
// Neki-iOS
4+
//
5+
// Created by SwainYun on 3/24/26.
6+
//
7+
8+
import Foundation
9+
import os
10+
11+
public enum QRCodeScannerEndpoint {
12+
case notifyUnsupportedBrand(url: URL, user: User)
13+
}
14+
15+
16+
// MARK: - QRCodeScannerEndpoint + Endpoint
17+
18+
extension QRCodeScannerEndpoint: Endpoint {
19+
public var baseURL: String {
20+
switch self {
21+
case .notifyUnsupportedBrand:
22+
guard let webhookURLString = Bundle.main.infoDictionary?["QR_WEBHOOK_URL"] as? String else {
23+
Logger.data.fault("QR_WEBHOOK_URL을 번들에서 찾을 수 없음.")
24+
return ""
25+
}
26+
return webhookURLString
27+
}
28+
}
29+
30+
public var path: String {
31+
switch self {
32+
case .notifyUnsupportedBrand: return ""
33+
}
34+
}
35+
36+
public var method: HTTPMethodType {
37+
switch self {
38+
case .notifyUnsupportedBrand: return .post
39+
}
40+
}
41+
42+
public var authorizationType: AuthorizationType { return .none }
43+
44+
public var contentType: HTTPContentType { return .json }
45+
46+
public var body: (any Encodable)? {
47+
switch self {
48+
case let .notifyUnsupportedBrand(url, user): return DiscordWebhookDTO.Request(unsupportedURL: url, user: user)
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)