Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ repositories {
maven {
url "https://maven.dcm4che.org"
}
jcenter()
}

dependencies {
Expand Down Expand Up @@ -72,15 +73,15 @@ dependencies {
// WebJars Locator
implementation 'org.webjars:webjars-locator:0.46'

//
//
implementation ("org.webjars.bower:bootstrap:5.2.2")
implementation ("org.webjars.bower:demo-console:1.5.1")
implementation ("org.webjars.bower:draggabilly:2.1.0")
implementation ("org.webjars.bower:ekko-lightbox:5.2.0")
implementation ("org.webjars.bower:jquery:3.6.1")
implementation ("org.webjars.bower:jsnlog.js:2.20.1")
implementation ("org.webjars.bower:webrtc-adapter:7.4.0")

implementation("org.kurento:kurento-commons:7.1.0")
implementation("org.kurento:kurento-client:7.1.0")
implementation("org.kurento:kurento-utils-js:7.1.0")
Expand All @@ -93,6 +94,9 @@ dependencies {

testImplementation 'org.testcontainers:postgresql:1.19.7'

implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation 'com.google.firebase:firebase-admin:9.2.0'

}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ data class Reminder(
): BaseModel

data class ReminderItem(
val remindAt: LocalDateTime?,
val remindAt: String?,
val description: String?
)
){

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ data class Todos(
data class Todo(
val executor: String?,
val description: String?,
val dueDate: LocalDateTime?,
val dueDate: String?,
val context: String?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.openfuture.openmessenger.component.state

import io.openfuture.openmessenger.repository.entity.BlockchainType
import io.openfuture.openmessenger.service.dto.StateWalletDto
import org.springframework.http.MediaType
import org.springframework.stereotype.Component
import org.springframework.web.reactive.function.BodyInserters
import org.springframework.web.reactive.function.client.WebClient


@Component
class DefaultStateApi(
private val stateWebClient: WebClient
) : StateApi {

override fun createWallet(
address: String,
webHook: String,
blockchain: BlockchainType,
applicationId: String
): StateWalletDto? {
val request = CreateStateWalletRequest(address, applicationId, blockchain.getValue(), webHook)
println("State save request $request")
return stateWebClient
.post()
.uri("http://localhost:8545/api/wallets/single")
.accept(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromValue(request))
.retrieve()
.bodyToMono(StateWalletDto::class.java)
.block()
}

data class CreateStateWalletRequest(
val address: String,
val applicationId: String,
val blockchain: String,
val webhook: String
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.openfuture.openmessenger.component.state

import io.openfuture.openmessenger.repository.entity.BlockchainType
import io.openfuture.openmessenger.service.dto.StateWalletDto

interface StateApi {
fun createWallet(address: String, webHook: String, blockchain: BlockchainType, applicationId: String): StateWalletDto?
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.openfuture.openmessenger.configuration

import io.openfuture.openmessenger.security.AwsCognitoTokenFilter
import io.openfuture.openmessenger.security.CognitoAuthenticationProvider
import jakarta.servlet.http.HttpServletRequest
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.security.config.Customizer
Expand All @@ -14,9 +13,6 @@ import org.springframework.security.config.annotation.web.configurers.SessionMan
import org.springframework.security.config.http.SessionCreationPolicy
import org.springframework.security.web.SecurityFilterChain
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
import org.springframework.web.cors.CorsConfiguration
import org.springframework.web.cors.CorsConfigurationSource
import org.springframework.web.cors.UrlBasedCorsConfigurationSource

@Configuration
@EnableWebSecurity
Expand All @@ -36,6 +32,8 @@ class SecurityConfig(
.authorizeHttpRequests {
it.requestMatchers("/api/v1/public/login").permitAll()
it.requestMatchers("/api/v1/public/signup").permitAll()
it.requestMatchers("/api/v1/refreshToken").permitAll()
it.requestMatchers("/api/v1/wallets/webhook").permitAll()
it.requestMatchers("/api/v1/attachments/download/**").permitAll()
it.requestMatchers("/*").permitAll()
it.requestMatchers("/webjars/**").permitAll()
Expand All @@ -52,7 +50,9 @@ class SecurityConfig(
"/api/v1/public/login",
"/api/v1/public/signup",
"/api/v1/attachments/download/**",
listOf("/*", "/webjars/**", "/js/*", "/img/*", "/css/*", "/video/*")
listOf("/*", "/webjars/**", "/js/*", "/img/*", "/css/*", "/video/*"),
"/api/v1/refreshToken",
"/api/v1/wallets/webhook"
),
UsernamePasswordAuthenticationFilter::class.java
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.openfuture.openmessenger.configuration

import io.openfuture.openmessenger.configuration.property.StateProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.reactive.function.client.WebClient


@Configuration
class StateConfig {

@Bean
fun stateClient(stateProperties: StateProperties): WebClient =
WebClient.builder()
.baseUrl(stateProperties.baseUrl!!)
.build()

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.openfuture.openmessenger.configuration.property

import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.stereotype.Component
import org.springframework.validation.annotation.Validated
import javax.validation.constraints.NotBlank
import javax.validation.constraints.NotNull

@ConfigurationProperties(prefix = "state")
@Validated
@Component
data class StateProperties(@field:NotNull @field:NotBlank var baseUrl: String?)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.openfuture.openmessenger.repository

import io.openfuture.openmessenger.repository.entity.BlockchainContractEntity
import io.openfuture.openmessenger.repository.entity.BlockchainType
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query

interface BlockchainContractRepository : JpaRepository<BlockchainContractEntity, Long> {
@Query("SELECT t from BlockchainContractEntity t where t.blockchain = :blockchain and t.isTest = :isTest")
fun findFirstByBlockchain(blockchain: BlockchainType, isTest: Boolean) : BlockchainContractEntity?

@Query("SELECT t from BlockchainContractEntity t where t.isTest = :isTest")
fun findAllByIsTest(isTest: Boolean) : List<BlockchainContractEntity>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.openfuture.openmessenger.repository

import io.openfuture.openmessenger.repository.entity.TaskEntity
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query

interface TaskRepository : JpaRepository<TaskEntity, Long> {
@Query("SELECT t from TaskEntity t where t.assignee = :emailAddress or t.assignor =:emailAddress ")
fun findAllByAssigneeOrAssignor(emailAddress: String) : List<TaskEntity>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.openfuture.openmessenger.repository

import io.openfuture.openmessenger.repository.entity.UserFireBaseToken
import org.springframework.data.jpa.repository.JpaRepository
import java.util.Optional

interface UserFirebaseTokenRepository : JpaRepository<UserFireBaseToken, Long> {
fun findAllByUserId(userId: String): List<UserFireBaseToken>
fun findFirstByUserId(userId: String): Optional<UserFireBaseToken>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.openfuture.openmessenger.repository

import io.openfuture.openmessenger.repository.entity.WalletEntity
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query

interface WalletRepository : JpaRepository<WalletEntity, Long> {
@Query("SELECT t from WalletEntity t where t.userId =:userId ")
fun findAllByUserId(userId: String) : List<WalletEntity>

@Query("SELECT t from WalletEntity t where lower(t.address) =:address ")
fun findFirstByAddress(address: String) : WalletEntity?

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.openfuture.openmessenger.repository.entity

import jakarta.persistence.*
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalDateTime.now

@Entity
@Table(name = "blockchain_contracts")
class BlockchainContractEntity() {
constructor(
contractAddress: String,
contractName: String,
decimal: Int,
blockchain: BlockchainType,
isTest: Boolean
): this() {
this.contractName = contractName
this.contractAddress = contractAddress
this.blockchain = blockchain
this.isTest = isTest
this.decimal = decimal
this.createdAt = now()
this.updatedAt = now()
}

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
var id: Long? = null
var createdAt: LocalDateTime? = now()
var updatedAt: LocalDateTime? = now()
var isTest: Boolean = false
@Enumerated(EnumType.STRING)
var blockchain: BlockchainType = BlockchainType.BTC
var contractAddress: String? = null
var contractName: String? = null
var decimal: Int? = 6
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.openfuture.openmessenger.repository.entity

import io.openfuture.openmessenger.repository.entity.base.Dictionary


enum class BlockchainType(
private val id: Int,
private val value: String
) : Dictionary {

ETH(1, "ETH"),
BTC(2, "BTC"),
BNB(3, "BNB"),
TRX(4, "TRX")
;

override fun getId(): Int = id

fun getValue(): String = value

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.openfuture.openmessenger.repository.entity

import jakarta.persistence.*
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalDateTime.now

@Entity
@Table(name = "open_tasks")
class TaskEntity() {
constructor(
assignor: String?,
assignee: String?,
taskTitle: String?,
taskDescription: String?,
taskDate: LocalDate?
): this() {
this.assignee = assignee
this.assignor = assignor
this.taskTitle = taskTitle
this.taskDescription = taskDescription
this.taskDate = taskDate
this.createdAt = now()
this.updatedAt = now()
}

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
var id: Long? = null
var createdAt: LocalDateTime? = now()
var updatedAt: LocalDateTime? = now()
var assignor: String? = null
var assignee: String? = null
var taskTitle: String? = null
var taskDescription: String? = null
var taskDate: LocalDate? = LocalDate.now()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.openfuture.openmessenger.repository.entity

import jakarta.persistence.*
import java.time.LocalDateTime

@Entity
@Table(name = "user_firebase_tokens")
class UserFireBaseToken() {
constructor(
userId: String,
token: String
) : this() {
this.userId = userId
this.firebaseToken = token
this.createdAt = LocalDateTime.now()
this.updatedAt = LocalDateTime.now()
}

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
var id: Long? = null
var createdAt: LocalDateTime = LocalDateTime.now()
var updatedAt: LocalDateTime = LocalDateTime.now()
var userId: String? = null
var firebaseToken: String? = null

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.openfuture.openmessenger.repository.entity

import jakarta.persistence.*
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalDateTime.now

@Entity
@Table(name = "open_wallets")
class WalletEntity() {
constructor(
address: String,
blockchainType: BlockchainType,
userId: String
): this() {
this.address = address
this.userId = userId
this.blockchainType = blockchainType
this.createdAt = now()
this.updatedAt = now()
}

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
var id: Long? = null
var createdAt: LocalDateTime? = now()
var updatedAt: LocalDateTime? = now()
var address: String? = null
@Enumerated(EnumType.STRING)
var blockchainType: BlockchainType = BlockchainType.BTC
var balance: String? = null
var userId: String? = null
}
Loading
Loading