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
14 changes: 9 additions & 5 deletions flushall_build_and_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,23 @@ JAVA_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED \
--add-opens java.base/java.util.jar=ALL-UNNAMED \
--add-opens java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED"

RUNTIME_LOG=/tmp/obp-api.log

if [ "$RUN_BACKGROUND" = true ]; then
# Run in background with output to log file
nohup java $JAVA_OPTS -jar obp-api/target/obp-api.jar > http4s-server.log 2>&1 &
# Run in background with output to log file (tee'd to /tmp as well)
nohup java $JAVA_OPTS -jar obp-api/target/obp-api.jar > >(tee "$RUNTIME_LOG") 2>&1 &
SERVER_PID=$!
echo "✓ HTTP4S server started in background"
echo " PID: $SERVER_PID"
echo " Log: http4s-server.log"
echo " Log: http4s-server.log (also $RUNTIME_LOG)"
echo ""
echo "To stop the server: kill $SERVER_PID"
echo "To view logs: tail -f http4s-server.log"
else
# Run in foreground (Ctrl+C to stop)
# Run in foreground (Ctrl+C to stop). Also tee output to /tmp so it can be
# tailed from another terminal without taking over this one.
echo "Press Ctrl+C to stop the server"
echo "Runtime log also written to: $RUNTIME_LOG"
echo ""
java $JAVA_OPTS -jar obp-api/target/obp-api.jar
java $JAVA_OPTS -jar obp-api/target/obp-api.jar 2>&1 | tee "$RUNTIME_LOG"
fi
19 changes: 14 additions & 5 deletions obp-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,25 @@
<artifactId>scalapb-runtime-grpc_${scala.version}</artifactId>
<version>0.8.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.grpc/grpc-all -->
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-all</artifactId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.48.1</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.27.Final</version>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.48.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.48.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
<version>1.48.1</version>
</dependency>
<dependency>
<groupId>org.asynchttpclient</groupId>
Expand Down
68 changes: 68 additions & 0 deletions obp-api/src/main/protobuf/chat.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
syntax = "proto3";
package code.obp.grpc.chat.g1;

import "google/protobuf/timestamp.proto";

message StreamMessagesRequest {
string chat_room_id = 1;
}

// Fields match ChatMessageJsonV600 exactly, plus event_type for stream events
message ChatMessageEvent {
string event_type = 1;
string chat_message_id = 2;
string chat_room_id = 3;
string sender_user_id = 4;
string sender_consumer_id = 5;
string sender_username = 6;
string sender_provider = 7;
string sender_consumer_name = 8;
string content = 9;
string message_type = 10;
repeated string mentioned_user_ids = 11;
string reply_to_message_id = 12;
string thread_id = 13;
bool is_deleted = 14;
google.protobuf.Timestamp created_at = 15;
google.protobuf.Timestamp updated_at = 16;
}

message TypingEvent {
string chat_room_id = 1;
bool is_typing = 2;
}

// Fields match TypingUserJsonV600
message TypingIndicator {
string chat_room_id = 1;
string user_id = 2;
string username = 3;
string provider = 4;
bool is_typing = 5;
}

message StreamPresenceRequest {
string chat_room_id = 1;
}

message PresenceEvent {
string user_id = 1;
string username = 2;
string provider = 3;
bool is_online = 4;
}

message StreamUnreadCountsRequest {
}

message UnreadCountEvent {
string chat_room_id = 1;
int64 unread_count = 2;
}

service ChatStreamService {
rpc StreamMessages(StreamMessagesRequest) returns (stream ChatMessageEvent);
rpc StreamTyping(stream TypingEvent) returns (stream TypingIndicator);
rpc StreamPresence(StreamPresenceRequest) returns (stream PresenceEvent);
rpc StreamUnreadCounts(StreamUnreadCountsRequest) returns (stream UnreadCountEvent);
}
9 changes: 6 additions & 3 deletions obp-api/src/main/resources/props/sample.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -1196,10 +1196,13 @@ database_messages_scheduler_interval=3600
# GRPC
# the default GRPC is disabled
# grpc.server.enabled = false
# If do not set this props, the grpc port will be set randomly when OBP starts.
# And you can call `Get API Configuration` endpoint to see the `grpc_port` there.
# When you set this props, need to make sure this port is available.
# The default gRPC port is 50051. Override if needed.
# grpc.server.port = 50051
# When gRPC is enabled, chat streaming services (StreamMessages, StreamTyping,
# StreamPresence, StreamUnreadCounts) are available on the same port.
# Clients authenticate via the "authorization" metadata key using the same
# DirectLogin or OAuth tokens as the REST API.
# See src/main/protobuf/chat.proto for the service contract.

# Create System Views At Boot -----------------------------------------------
# In case is not defined default value is true
Expand Down
14 changes: 11 additions & 3 deletions obp-api/src/main/scala/bootstrap/liftweb/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ import code.migration.MigrationScriptLog
import code.model._
import code.model.dataAccess._
import code.model.dataAccess.internalMapping.AccountIdMapping
import code.obp.grpc.HelloWorldServer
import code.obp.grpc.ObpGrpcServer
import code.productAttributeattribute.MappedProductAttribute
import code.productcollection.MappedProductCollection
import code.productcollectionitem.MappedProductCollectionItem
Expand All @@ -131,6 +131,7 @@ import code.transaction_types.MappedTransactionType
import code.transactionattribute.MappedTransactionAttribute
import code.transactionrequests.{MappedTransactionRequest, MappedTransactionRequestTypeCharge, TransactionRequestReasons}
import code.usercustomerlinks.MappedUserCustomerLink
import code.customerlinks.CustomerLink
import code.userlocks.UserLocks
import code.users._
import code.util.Helper.{MdcLoggable, ObpS, SILENCE_IS_GOLDEN}
Expand Down Expand Up @@ -761,6 +762,8 @@ class Boot extends MdcLoggable {

def schemifyAll() = {
Schemifier.schemify(true, Schemifier.infoF _, ToSchemify.models: _*)
// Create default system-level "general" chat room (all_users_are_participants = true)
code.chat.ChatRoomTrait.chatRoomProvider.vend.getOrCreateDefaultRoom()
}

private def showExceptionAtJson(error: Throwable): String = {
Expand Down Expand Up @@ -1161,6 +1164,7 @@ object ToSchemify {
MappedNarrative,
MappedCustomer,
MappedUserCustomerLink,
CustomerLink,
Consumer,
Token,
OpenIDConnectToken,
Expand Down Expand Up @@ -1203,12 +1207,16 @@ object ToSchemify {
CounterpartyAttributeMapper,
BankAccountBalance,
Group,
AccountAccessRequest
AccountAccessRequest,
code.chat.ChatRoom,
code.chat.Participant,
code.chat.ChatMessage,
code.chat.Reaction
)

// start grpc server
if (APIUtil.getPropsAsBoolValue("grpc.server.enabled", false)) {
val server = new HelloWorldServer(ExecutionContext.global)
val server = new ObpGrpcServer(ExecutionContext.global)
server.start()
LiftRules.unloadHooks.append(server.stop)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6103,6 +6103,75 @@ object SwaggerDefinitionsJSON {
List(counterpartyAttributeResponseJsonV600)
)

lazy val postCustomerLinkJsonV600 = PostCustomerLinkJsonV600(
customer_id = customerIdExample.value,
other_bank_id = bankIdExample.value,
other_customer_id = customerIdExample.value,
relationship_to = "spouse"
)

lazy val putCustomerLinkJsonV600 = PutCustomerLinkJsonV600(
relationship_to = "close_associate"
)

lazy val customerLinkJsonV600 = CustomerLinkJsonV600(
customer_link_id = "613c83ea-80f9-4560-8404-b9cd4ec42a7f",
bank_id = bankIdExample.value,
customer_id = customerIdExample.value,
other_bank_id = bankIdExample.value,
other_customer_id = customerIdExample.value,
relationship_to = "spouse",
date_inserted = DateWithDayExampleObject,
date_updated = DateWithDayExampleObject
)

lazy val customerLinksJsonV600 = CustomerLinksJsonV600(
List(customerLinkJsonV600)
)

lazy val investigationTransactionJsonV600 = InvestigationTransactionJsonV600(
transaction_id = transactionIdExample.value,
account_id = accountIdExample.value,
amount = "1250",
currency = currencyExample.value,
transaction_type = "DEBIT",
description = "Payment for consulting services",
start_date = DateWithDayExampleObject,
finish_date = DateWithDayExampleObject,
counterparty_name = "ACME Corp",
counterparty_account = "DE89370400440532013000",
counterparty_bank_name = "Deutsche Bank"
)

lazy val investigationAccountJsonV600 = InvestigationAccountJsonV600(
account_id = accountIdExample.value,
bank_id = bankIdExample.value,
currency = currencyExample.value,
balance = "150000",
account_name = "Current Account",
account_type = "CURRENT",
transactions = List(investigationTransactionJsonV600)
)

lazy val investigationCustomerLinkJsonV600 = InvestigationCustomerLinkJsonV600(
customer_link_id = "613c83ea-80f9-4560-8404-b9cd4ec42a7f",
other_customer_id = customerIdExample.value,
other_bank_id = bankIdExample.value,
relationship = "spouse",
other_legal_name = "Jane Doe"
)

lazy val investigationReportJsonV600 = InvestigationReportJsonV600(
customer_id = customerIdExample.value,
legal_name = "John Doe",
bank_id = bankIdExample.value,
accounts = List(investigationAccountJsonV600),
related_customers = List(investigationCustomerLinkJsonV600),
from_date = DateWithDayExampleObject,
to_date = DateWithDayExampleObject,
data_source = "mapped_database"
)

lazy val bankAccountBalanceRequestJsonV510 = BankAccountBalanceRequestJsonV510(
balance_type = balanceTypeExample.value,
balance_amount = balanceAmountExample.value
Expand Down
34 changes: 33 additions & 1 deletion obp-api/src/main/scala/code/api/util/ApiRole.scala
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,25 @@ object ApiRole extends MdcLoggable{

case class CanGetCustomerAccountLinks(requiresBankId: Boolean = true) extends ApiRole
lazy val canGetCustomerAccountLinks = CanGetCustomerAccountLinks()


case class CanCreateCustomerLink(requiresBankId: Boolean = true) extends ApiRole
lazy val canCreateCustomerLink = CanCreateCustomerLink()

case class CanUpdateCustomerLink(requiresBankId: Boolean = true) extends ApiRole
lazy val canUpdateCustomerLink = CanUpdateCustomerLink()

case class CanDeleteCustomerLink(requiresBankId: Boolean = true) extends ApiRole
lazy val canDeleteCustomerLink = CanDeleteCustomerLink()

case class CanGetCustomerLink(requiresBankId: Boolean = true) extends ApiRole
lazy val canGetCustomerLink = CanGetCustomerLink()

case class CanGetCustomerLinks(requiresBankId: Boolean = true) extends ApiRole
lazy val canGetCustomerLinks = CanGetCustomerLinks()

case class CanGetInvestigationReport(requiresBankId: Boolean = true) extends ApiRole
lazy val canGetInvestigationReport = CanGetInvestigationReport()

case class CanCreateBranch(requiresBankId: Boolean = true) extends ApiRole
lazy val canCreateBranch = CanCreateBranch()

Expand Down Expand Up @@ -1352,6 +1370,20 @@ object ApiRole extends MdcLoggable{
case class CanGetAccountDirectoryAtOneBank(requiresBankId: Boolean = true) extends ApiRole
lazy val canGetAccountDirectoryAtOneBank = CanGetAccountDirectoryAtOneBank()

// Chat Room roles
case class CanDeleteBankChatRoom(requiresBankId: Boolean = true) extends ApiRole
lazy val canDeleteBankChatRoom = CanDeleteBankChatRoom()
case class CanDeleteSystemChatRoom(requiresBankId: Boolean = false) extends ApiRole
lazy val canDeleteSystemChatRoom = CanDeleteSystemChatRoom()
case class CanArchiveBankChatRoom(requiresBankId: Boolean = true) extends ApiRole
lazy val canArchiveBankChatRoom = CanArchiveBankChatRoom()
case class CanArchiveSystemChatRoom(requiresBankId: Boolean = false) extends ApiRole
lazy val canArchiveSystemChatRoom = CanArchiveSystemChatRoom()
case class CanSetBankChatRoomAUAP(requiresBankId: Boolean = true) extends ApiRole
lazy val canSetBankChatRoomAUAP = CanSetBankChatRoomAUAP()
case class CanSetSystemChatRoomAUAP(requiresBankId: Boolean = false) extends ApiRole
lazy val canSetSystemChatRoomAUAP = CanSetSystemChatRoomAUAP()

private val dynamicApiRoles = new ConcurrentHashMap[String, ApiRole]

private case class DynamicApiRole(role: String, requiresBankId: Boolean = false) extends ApiRole{
Expand Down
2 changes: 2 additions & 0 deletions obp-api/src/main/scala/code/api/util/ApiTag.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ object ApiTag {
val apiTagAggregateMetrics = ResourceDocTag("Aggregate-Metrics")
val apiTagSystemIntegrity = ResourceDocTag("System-Integrity")
val apiTagBalance = ResourceDocTag("Balance")
val apiTagChat = ResourceDocTag("Chat")
val apiTagGroup = ResourceDocTag("Group")
val apiTagWebhook = ResourceDocTag("Webhook")
val apiTagMockedData = ResourceDocTag("Mocked-Data")
Expand Down Expand Up @@ -164,6 +165,7 @@ object ApiTag {
val apiTagSignal = ResourceDocTag("Signal")
val apiTagSignalling = ResourceDocTag("Signalling")
val apiTagChannel = ResourceDocTag("Channel")
val apiTagFinancialCrime = ResourceDocTag("Financial-Crime")

private[this] val tagNameSymbolMapTag: MutableMap[String, ResourceDocTag] = MutableMap()

Expand Down
Loading
Loading