Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#464 이미지 s3 도입 #479

Merged
merged 26 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1d873ec
feat: 이미지를 저장할 수 있는 ImageService 및 ImageClient 생성
hectick Oct 6, 2023
5a0865b
refactor: 로컬 환경에서 이미지를 저장, 삭제할 때 ImageFileUploader 대신 LocalImageClien…
hectick Oct 6, 2023
cddb4c9
refactor: 게시글, 댓글 조회시 이미지 url을 Domain을 통해서가 아니라 ImageService를 통해서 알아내…
hectick Oct 6, 2023
2e7fa41
refactor: properties 파일의 domain 변수명을 image.domain으로 구체화 및 테스트 코드 추가
hectick Oct 6, 2023
7b00a10
fix: 이미지 삭제 버그 수정
hectick Oct 6, 2023
8a2247c
refactor: 메서드명 수정
hectick Oct 6, 2023
947af09
feat: prod 환경에서 s3에 이미지를 저장하는 기능 구현
hectick Oct 10, 2023
36efbbc
Merge remote-tracking branch 'origin/dev' into feat/#464_이미지_s3_도입
hectick Oct 10, 2023
970d320
refactor: application-prod.properties 다듬기
hectick Oct 10, 2023
9fb67b8
fix: S3Client configuration
hectick Oct 10, 2023
2743167
fix: final 제거
hectick Oct 10, 2023
da9f56f
fix: contentType 지정
hectick Oct 10, 2023
39a5b0f
refactor: 주석 제거
hectick Oct 10, 2023
ea1f06b
feat: 이미지 s3로 이주하는 api 생성
hectick Oct 13, 2023
69b8b73
Merge remote-tracking branch 'origin/dev' into feat/#464_이미지_s3_도입
hectick Oct 18, 2023
ebe422d
fix: 머지 후 애플리케이션 동작하도록 코드 수정
hectick Oct 18, 2023
55e18df
refactor:
hectick Oct 18, 2023
9e46be3
Merge remote-tracking branch 'origin/dev' into feat/#464_이미지_s3_도입
hectick Oct 18, 2023
2e05fb6
refactor: 어노테이션 순서 변경
hectick Oct 18, 2023
e37c0fe
docs: 회원정보수정 문서화 수정
hectick Oct 18, 2023
ed721e0
refactor: 변수명 변경
hectick Oct 18, 2023
bef925f
refactor: 캡슐화
hectick Oct 18, 2023
1880dea
refactor: ImageInfoFactory 클래스 분리 및 image 관련 클래스들 패키지 변경
hectick Oct 18, 2023
de6231a
refactor: 오래된 파일 경로 원상복구
hectick Oct 18, 2023
b435108
feat: 프로필 자동 삭제 기능 도입
hectick Oct 18, 2023
d7cda0b
Merge remote-tracking branch 'origin/dev' into feat/#464_이미지_s3_도입
hectick Oct 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/android-ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ jobs:
env:
BASE_URL: ${{ secrets.APP_BASE_URL }}
run: |
echo APP_BASE_URL=\"BASE_URL\" >> ./local.properties
echo "APP_BASE_URL=\"BASE_URL\"" >> ./local.properties

- name: Access KAKAO KEY
env:
APP_KEY: ${{ secrets.KAKAO_APP_KEY }}
NATIVE_KEY: ${{ secrets.KAKAO_NATIVE_KEY }}
run: |
echo KAKAO_APP_KEY=\"APP_KEY\" >> ./local.properties
echo KAKAO_NATIVE_KEY=\"NATIVE_KEY\" >> ./local.properties
echo "KAKAO_APP_KEY=\"APP_KEY\"" >> ./local.properties
echo "KAKAO_NATIVE_KEY=\"NATIVE_KEY\"" >> ./local.properties

- name: set up Java JDK 17
uses: actions/setup-java@v3
Expand Down
5 changes: 3 additions & 2 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android {
applicationId = "app.edonymyeon"
minSdk = 28
targetSdk = 33
versionCode = 11
versionCode = 12
versionName = "1.0.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -48,7 +48,8 @@ android {
)

val kakaoNativeKey = localProperties.getProperty("KAKAO_NATIVE_KEY")
manifestPlaceholders["KAKAO_NATIVE_KEY"] = kakaoNativeKey.substring(1, kakaoNativeKey.length - 1)
manifestPlaceholders["KAKAO_NATIVE_KEY"] =
kakaoNativeKey.substring(1, kakaoNativeKey.length - 1)
}

buildTypes {
Expand Down
46 changes: 36 additions & 10 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<activity
android:name="com.app.edonymyeon.presentation.ui.imagedetail.ImageDetailActivity"
android:exported="false" />
<activity
android:name="com.app.edonymyeon.presentation.ui.profileupdate.ProfileUpdateActivity"
android:exported="false" />
<activity
android:name="com.app.edonymyeon.presentation.ui.alarmsetting.AlarmSettingActivity"
android:exported="false" />
Expand All @@ -51,7 +54,8 @@
android:exported="true" />
<activity
android:name="com.app.edonymyeon.presentation.ui.main.MainActivity"
android:exported="true">
android:exported="true"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -71,14 +75,6 @@
android:name="com.app.edonymyeon.presentation.ui.post.PostActivity"
android:exported="true" />

<service
android:name="com.app.edonymyeon.data.service.fcm.AlarmService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

<activity
android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
android:exported="true">
Expand All @@ -93,6 +89,36 @@
android:scheme="${KAKAO_NATIVE_KEY}" />
</intent-filter>
</activity>
</application>

<service
android:name="com.app.edonymyeon.data.service.fcm.AlarmService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

<service
android:name="com.google.android.gms.metadata.ModuleDependencies"
android:enabled="false"
android:exported="false"
tools:ignore="MissingClass">
<intent-filter>
<action android:name="com.google.android.gms.metadata.MODULE_DEPENDENCIES" />
</intent-filter>
<meta-data
android:name="photopicker_activity:0:required"
android:value="" />
</service>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.app.edonymyeon.data.common
import org.json.JSONObject
import retrofit2.Response

fun <T : Any> createCustomThrowableFromResponse(result: Response<T>): CustomThrowable {
fun <T> createCustomThrowableFromResponse(result: Response<T>): CustomThrowable {
val errorResponse = result.errorBody()?.string()
val json = errorResponse?.let { JSONObject(it) }
val errorMessage = json?.getString("errorMessage") ?: ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.app.edonymyeon.data.common

sealed class FetchState {
object BadInternet : FetchState()
object ParseError : FetchState()
object WrongConnection : FetchState()
sealed interface FetchState {
object BadInternet : FetchState
object ParseError : FetchState
object WrongConnection : FetchState

object Fail : FetchState()
class NoAuthorization(
val customThrowable: CustomThrowable,
) : FetchState

class Fail(
val customThrowable: CustomThrowable,
) : FetchState
}
14 changes: 14 additions & 0 deletions android/app/src/main/java/com/app/edonymyeon/data/common/Result.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.app.edonymyeon.data.common

sealed class Result<T> {

class Success<T>(val data: T, val code: Int) : Result<T>()

class ApiError<T>(val customThrowable: CustomThrowable) : Result<T>()

class UnKnownApiError<T>(val code: Int) : Result<T>()

class NetworkError<T>(val fetchState: FetchState) : Result<T>()

class NullResult<T> : Result<T>()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.app.edonymyeon.data.datasource.auth

import android.util.Log
import com.app.edonymyeon.data.dto.LoginDataModel
import com.app.edonymyeon.data.dto.request.LogoutRequest
import com.app.edonymyeon.data.dto.request.TokenRequest
Expand Down Expand Up @@ -30,7 +29,6 @@ class AuthRemoteDataSource @Inject constructor(
}

override suspend fun logout(logoutRequest: LogoutRequest): Response<Unit> {
Log.d("testLog", logoutRequest.deviceToken)
return authService.logout(logoutRequest)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.app.edonymyeon.data.repository

import com.app.edonymyeon.data.common.CustomThrowable
import com.app.edonymyeon.data.common.createCustomThrowableFromResponse
import com.app.edonymyeon.data.datasource.auth.AuthDataSource
import com.app.edonymyeon.data.dto.LoginDataModel
Expand All @@ -10,7 +9,6 @@ import com.app.edonymyeon.data.dto.response.AuthDuplicateResponse
import com.app.edonymyeon.mapper.toDataModel
import com.domain.edonymyeon.model.UserRegistration
import com.domain.edonymyeon.repository.AuthRepository
import org.json.JSONObject
import javax.inject.Inject

class AuthRepositoryImpl @Inject constructor(
Expand All @@ -33,7 +31,8 @@ class AuthRepositoryImpl @Inject constructor(
return if (result.isSuccessful) {
Result.success(Unit)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}

Expand All @@ -46,7 +45,8 @@ class AuthRepositoryImpl @Inject constructor(
return if (result.isSuccessful) {
Result.success((result.body() ?: AuthDuplicateResponse(false)).isUnique)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}

Expand All @@ -69,10 +69,8 @@ class AuthRepositoryImpl @Inject constructor(
authLocalDataSource.setAuthToken(result.headers()["Set-Cookie"] as String)
Result.success(result.body() ?: Unit)
} else {
val errorResponse = result.errorBody()?.string()
val json = errorResponse?.let { JSONObject(it) }
val errorMessage = json?.getString("errorMessage") ?: ""
Result.failure(CustomThrowable(result.code(), errorMessage))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}

Expand All @@ -82,7 +80,8 @@ class AuthRepositoryImpl @Inject constructor(
authLocalDataSource.setAuthToken(null)
Result.success(Unit)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.app.edonymyeon.data.repository

import com.app.edonymyeon.data.common.CustomThrowable
import com.app.edonymyeon.data.common.createCustomThrowableFromResponse
import com.app.edonymyeon.data.datasource.consumptions.ConsumptionsDataSource
import com.app.edonymyeon.data.dto.response.ConsumptionsResponse
import com.app.edonymyeon.mapper.toDomain
import com.domain.edonymyeon.repository.ConsumptionsRepository
import org.json.JSONObject
import javax.inject.Inject

class ConsumptionsRepositoryImpl @Inject constructor(
Expand All @@ -17,10 +16,8 @@ class ConsumptionsRepositoryImpl @Inject constructor(
return if (result.isSuccessful) {
Result.success((result.body() as ConsumptionsResponse).toDomain())
} else {
val errorResponse = result.errorBody()?.string()
val json = errorResponse?.let { JSONObject(it) }
val errorMessage = json?.getString("errorMessage") ?: ""
Result.failure(CustomThrowable(result.code(), errorMessage))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.app.edonymyeon.data.repository

import com.app.edonymyeon.data.common.CustomThrowable
import com.app.edonymyeon.data.common.createCustomThrowableFromResponse
import com.app.edonymyeon.data.datasource.notification.NotificationDataSource
import com.app.edonymyeon.mapper.toDomain
import com.domain.edonymyeon.model.Notifications
Expand All @@ -14,7 +14,8 @@ class NotificationRepositoryImpl @Inject constructor(private val notificationDat
return if (result.isSuccessful && result.body() != null) {
Result.success(result.body()!!.toDomain())
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.app.edonymyeon.data.repository

import com.app.edonymyeon.data.common.CustomThrowable
import com.app.edonymyeon.data.common.createCustomThrowableFromResponse
import com.app.edonymyeon.data.datasource.post.PostDataSource
import com.app.edonymyeon.data.dto.response.CommentsResponse
Expand Down Expand Up @@ -33,7 +32,8 @@ class PostRepositoryImpl @Inject constructor(
return if (result.isSuccessful) {
Result.success(Unit)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}

Expand All @@ -49,7 +49,8 @@ class PostRepositoryImpl @Inject constructor(
),
)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}

Expand All @@ -61,7 +62,8 @@ class PostRepositoryImpl @Inject constructor(
return if (result.isSuccessful) {
Result.success(result.body() as PostEditorResponse)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}

Expand All @@ -76,7 +78,8 @@ class PostRepositoryImpl @Inject constructor(
return if (result.isSuccessful) {
Result.success(result.body() as PostEditorResponse)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}

Expand All @@ -92,7 +95,8 @@ class PostRepositoryImpl @Inject constructor(
),
)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}

Expand All @@ -109,7 +113,8 @@ class PostRepositoryImpl @Inject constructor(
),
)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}

Expand All @@ -118,7 +123,8 @@ class PostRepositoryImpl @Inject constructor(
return if (result.isSuccessful) {
Result.success(Unit)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}

Expand All @@ -127,7 +133,8 @@ class PostRepositoryImpl @Inject constructor(
return if (result.isSuccessful) {
Result.success(Unit)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.app.edonymyeon.data.repository

import com.app.edonymyeon.data.common.CustomThrowable
import com.app.edonymyeon.data.common.createCustomThrowableFromResponse
import com.app.edonymyeon.data.datasource.preference.PreferenceDataSource
import com.app.edonymyeon.data.dto.request.NotificationPreferenceRequest
import com.app.edonymyeon.mapper.toDomain
Expand All @@ -20,7 +20,8 @@ class PreferenceRepositoryImpl @Inject constructor(
},
)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}

Expand All @@ -35,7 +36,8 @@ class PreferenceRepositoryImpl @Inject constructor(
},
)
} else {
Result.failure(CustomThrowable(result.code(), result.message()))
val customThrowable = createCustomThrowableFromResponse(result)
Result.failure(customThrowable)
}
}
}
Loading