Skip to content

Commit fc20ead

Browse files
vanitha1822SauravBizbRollysac2kadamdrtechie5Amogh
authored
Video Consultation Functionality (#380)
* Update application.properties * add column in create BeneficiaryModel * Elasticsearch implementation for Beneficiary Search (#324) * fix: implement functionality to search beneficiaries with Elasticsearch * fix: remove unwanted import * fix: update pom.xml * fix: change the response code * variable added * update language * update language * Downgrade version from 3.6.1 to 3.6.0 * Elastic Search Implementation for Advanced Search (#327) * fix: cherry-pick commits for advanced search * fix: cherry-pick commit for token issue - mobile application * fix: add the missing properties * fix: add function to retrieve userid * fix: move the fetch Userid to jwtUtil * Remove empty line in application.properties * fix:signature check for mmu * Update application.properties * Update application.properties * fix: retrive any user without deleted * implement state wise hide un hide form fields * implement state wise hide un hide form fields * implement state wise hide un hide form fields * enhance welcome sms code * fix hide unhide form issue * docs: add DeepWiki badge and documentation link * Add DeepWiki badge to README Added DeepWiki badge to README for better visibility. * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * fix hide unhide form issue * chore(swagger): automate swagger sync to amrit-docs (#354) * chore(swagger): automate swagger sync to amrit-docs * chore(swagger): automate swagger sync to amrit-docs * chore(swagger): automate swagger sync to amrit-docs * Update the swagger json github workflow (#359) * chore(swagger): automate swagger sync to amrit-docs * chore(swagger): automate swagger sync to amrit-docs * chore(swagger): automate swagger sync to amrit-docs * fix(swagger): update the workflow and fix the running issue * fix(swagger): fix the swagger json workflow * chore(swagger): add fixed branch name in workflow * chore(ci): prevent multiple swagger sync PRs by using fixed branch * chore(swagger): add Dev/UAT/Demo servers to OpenAPI config * chore(swagger): avoid default server URLs * chore(swagger): remove field injection and inject URLs into OpenAPI bean * Add /health endpoint and standardize /version response (#331) * Add /health endpoint and standardize /version response * Add license headers and Javadocs to health and version controllers * Enhance /health endpoint to check Database and Redis connectivity * Improve /health endpoint HTTP status handling and logging * Enhance database health check with validation query * Refactor health controller to constructor injection and constants * Refactor: Extract business logic to HealthService to keep controller lean * Refactor: Extract business logic to HealthService to keep controller lean * Fix: Use ObjectProvider for optional health dependencies * Add advance health check for database (#361) * chore(swagger): automate swagger sync to amrit-docs * chore(swagger): automate swagger sync to amrit-docs * chore(swagger): automate swagger sync to amrit-docs * fix(swagger): update the workflow and fix the running issue * fix(swagger): fix the swagger json workflow * chore(swagger): add fixed branch name in workflow * chore(ci): prevent multiple swagger sync PRs by using fixed branch * chore(swagger): add Dev/UAT/Demo servers to OpenAPI config * chore(swagger): avoid default server URLs * chore(swagger): remove field injection and inject URLs into OpenAPI bean * feat(health,version): update version and health endpoints and add advance check for database * fix(health): normalize severity and fix slow query false positives * fix(health): avoid false CRITICAL on single long-running MySQL transaction * fix(health): enforce 3s DB connection timeout via HikariCP * Merge Release-3.8.0 (3.6.1) to Main (#379) * Move code to 3.6.1 to 3.8.0 (#372) * fix: cors spell fixes and import of packages updates * fix: deployment issue fix * feat: amm-1959 dhis token for cho report re-direction * fix: beneficiary history on revisit (#320) * fix: call type mapper (#322) * Elasticsearch implementation for Beneficiary Search (#324) * fix: implement functionality to search beneficiaries with Elasticsearch * fix: remove unwanted import * fix: update pom.xml * fix: change the response code * variable added * Elastic Search Implementation for Advanced Search (#327) * fix: cherry-pick commits for advanced search * fix: cherry-pick commit for token issue - mobile application * fix: add the missing properties * fix: add function to retrieve userid * fix: move the fetch Userid to jwtUtil * fix:signature check for mmu * fix: retrive any user without deleted * fix: update KM filepath * FLW-713 Remove All File Upload Options (#350) * FLW-713 Remove All File Upload Options * Fix UserServiceRoleRepo dependency issue and codeRabit comment * fixed coderabit comment * fix userMappingId issue * Add SMS functionality in release-3.6.1 (#358) * Enable SMS Functionality in MMU App to Send Prescriptions (#325) * fix: sms template save and map mmu (#306) * Vb/sms (#307) * fix: sms template save and map mmu * fix: enable mms for mmu prescription * Enable SMS Functionality in MMU App to Send Prescriptions (#325) * fix: sms template save and map mmu (#306) * Vb/sms (#307) * fix: sms template save and map mmu * fix: enable mms for mmu prescription --------- Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com> --------- Co-authored-by: 5Amogh <amoghavarsh@navadhiti.com> Co-authored-by: Vanitha S <116701245+vanitha1822@users.noreply.github.com> Co-authored-by: Sachin Kadam <152252767+sac2kadam@users.noreply.github.com> Co-authored-by: vanitha1822 <vanitha@navadhiti.com> Co-authored-by: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> * fix: add OTP rate limiting to prevent OTP flooding on sendConsent endpoint (#373) - Add OtpRateLimiterService with Redis-backed per-mobile rate limits (3/min, 10/hr, 20/day) - Add OtpRateLimitException for 429 responses - Integrate rate limiter in BeneficiaryOTPHandlerImpl and BeneficiaryConsentController - Add otp.ratelimit.* properties to common_ci and common_docker profiles - Update common_example.properties with new OTP rate limit config Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> * Health api (#376) * Cherry-pick health and version API enhancements to release-3.6.1 (#371) * feat(health,version): update version and health endpoints and add advance check for database * fix(health): normalize severity and fix slow query false positives * fix(health): avoid false CRITICAL on single long-running MySQL transaction * fix(health): enforce 3s DB connection timeout via HikariCP * Release 3.6.1 (#374) * feat(health,version): update version and health endpoints and add advance check for database * fix(health): normalize severity and fix slow query false positives * fix(health): avoid false CRITICAL on single long-running MySQL transaction * fix(health): enforce 3s DB connection timeout via HikariCP * feat(health): add healthcontroller and fix versioncontroller issues * fix: build error (#375) --------- Co-authored-by: KOPPIREDDY DURGA PRASAD <144464542+DurgaPrasad-54@users.noreply.github.com> Co-authored-by: Vanitha S <116701245+vanitha1822@users.noreply.github.com> --------- Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com> Co-authored-by: 5Amogh <amoghavarsh@navadhiti.com> Co-authored-by: Sachin Kadam <152252767+sac2kadam@users.noreply.github.com> Co-authored-by: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: KOPPIREDDY DURGA PRASAD <144464542+DurgaPrasad-54@users.noreply.github.com> * fix: video consultation functionality * fix: pom version update * fix: add cti-server-ip * fix: comment unwanted code * fix: update videocall url property * fix: update cti-server-ip * docs: add CLAUDE.md for Claude Code guidance Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: KM issue * fix: KM issue * fix: remove unwanted imports * fix: conflicts * fix: update the temp path * Fix the OpenKM Issue (#389) * fix: remove km in application.properties * fix: update all the properties to fetch from env * fix: update path * fix: KM issue * fix: get file from km * fix: build issue * fix: build issue * fix: remove unwanted imports * fix: build issue * fix: remove commented line * Enable KM configuration in common_example.properties Uncomment KM configuration properties for OpenKM. * Fix ConfigProperties to resolve env variable placeholders via Spring Environment (#390) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: update sms issue * fix: build issue * fix: update condition * fix: edit ben issue * fix: phone number issue for sms * fix: update the url with jwt token * fix: jitsi authorization issue * fix: skip auth * fix: hash key updation * fix: jwt type in header for authorization * fix: update file path * fix: vc recording path updation * fix: update video call recording functionality * fix: remove unwanted codes * fix: coderabbit comments --------- Co-authored-by: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Co-authored-by: Saurav Mishra <saurav.mishra@bizbrolly.com> Co-authored-by: Sachin Kadam <152252767+sac2kadam@users.noreply.github.com> Co-authored-by: Mithun James <drtechie@users.noreply.github.com> Co-authored-by: Amoghavarsh <93114621+5Amogh@users.noreply.github.com> Co-authored-by: vishwab1 <vishwanath@navadhiti.com> Co-authored-by: SnehaRH <77656297+snehar-nd@users.noreply.github.com> Co-authored-by: DurgaPrasad-54 <prasad8790237@gmail.com> Co-authored-by: KOPPIREDDY DURGA PRASAD <144464542+DurgaPrasad-54@users.noreply.github.com> Co-authored-by: Vaishnav Bhosale <vaishnavbharatbhosale@gmail.com> Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com> Co-authored-by: 5Amogh <amoghavarsh@navadhiti.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: SnehaRH <sneha@navadhiti.com>
1 parent b804de1 commit fc20ead

43 files changed

Lines changed: 1173 additions & 245 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# CLAUDE.md - Common-API
2+
3+
## Project Overview
4+
5+
Common-API is the gateway microservice for the AMRIT healthcare platform. It provides shared APIs consumed by all frontend UIs including authentication, beneficiary registration, call handling, location masters, notifications, feedback, reporting, and integrations with external systems (c-Zentrix CTI, Everwell, eAusadha, eSanjeevani, ABDM, Firebase, Honeywell POCT devices).
6+
7+
## Tech Stack
8+
9+
- Java 17
10+
- Spring Boot 3.2.2
11+
- Spring Data JPA / Hibernate
12+
- MySQL 8.0
13+
- Redis (session management, caching)
14+
- MongoDB (optional, for specific integrations)
15+
- Maven (build tool)
16+
- Swagger/OpenAPI (API documentation)
17+
- Lombok, MapStruct
18+
- CryptoJS-compatible AES encryption
19+
- Firebase Admin SDK
20+
- WAR packaging (deploys to Wildfly)
21+
22+
## Build and Run
23+
24+
```bash
25+
# Build
26+
mvn clean install -DENV_VAR=local
27+
28+
# Run locally (start Redis first)
29+
mvn spring-boot:run -DENV_VAR=local
30+
31+
# Package WAR
32+
mvn -B package --file pom.xml -P <profile> # profiles: dev, local, test, ci, uat
33+
34+
# Run tests
35+
mvn test
36+
```
37+
38+
### Configuration
39+
40+
- Copy `src/main/environment/common_example.properties` to `common_local.properties` and edit.
41+
- Environment selected via `-DENV_VAR=<env>`.
42+
- Swagger UI: `http://localhost:8083/swagger-ui.html`
43+
44+
## Package Structure
45+
46+
Base package: `com.iemr.common`
47+
48+
| Layer | Package | Description |
49+
|-------|---------|-------------|
50+
| Controllers | `controller.*` | REST endpoints (40+ sub-packages) |
51+
| Services | `service.*` | Business logic |
52+
| Repositories | `repository.*`, `repo.*` | JPA repositories |
53+
| Entities | `data.*` | JPA entity classes |
54+
| DTOs | `model.*` | Transfer objects |
55+
| Mappers | `mapper.*` | Object mapping |
56+
| Config | `config.*` | Swagger, encryption, Firebase, Quartz, prototypes |
57+
| Constants | `constant` | Application constants |
58+
| Utils | `utils.*` | Redis, HTTP, session, validation, exception |
59+
60+
## Key Functional Domains
61+
62+
- **Authentication/Authorization**: `controller.users` - login, session, user management
63+
- **Beneficiary Registration**: `controller.beneficiary` - create, search, update beneficiaries
64+
- **Call Handling**: `controller.callhandling` - CTI integration, call lifecycle
65+
- **Feedback/Grievance**: `controller.feedback`, `controller.grievance` - feedback and complaint management
66+
- **Location**: `controller.location` - state, district, block, village masters
67+
- **Notifications**: `controller.notification` - alerts, SMS, email, Firebase push
68+
- **Reporting**: `controller.report`, `controller.secondaryReport` - CRM reports
69+
- **Helpline 104**: `controller.helpline104history` - medical advice history
70+
- **COVID**: `controller.covid` - vaccination status
71+
- **CTI Integration**: `controller.cti` - c-Zentrix computer telephony
72+
- **External Integrations**: `controller.eausadha`, `controller.esanjeevani`, `controller.everwell`, `controller.honeywell`, `controller.brd`, `controller.carestream`
73+
- **ABDM**: `controller.abdmfacility` - Ayushman Bharat Digital Mission
74+
- **KM File Management**: `controller.kmfilemanager` - OpenKM document management
75+
- **OTP/SMS**: `controller.otp`, `controller.sms` (via SMS gateway)
76+
- **Scheduling**: `controller.questionconfig`, `controller.scheme`
77+
- **Door-to-Door App**: `controller.door_to_door_app` - field worker support
78+
- **NHM Dashboard**: `controller.nhmdashboard` - National Health Mission integration
79+
80+
## Architecture Notes
81+
82+
- Entry point: `CommonMain.java` (main class in `utils` package)
83+
- Acts as the API gateway; all frontend UIs authenticate through Common-API
84+
- Session management via Redis with 27-minute timeout
85+
- HTTP interceptors attach `Authorization` and `ServerAuthorization` headers
86+
- Status code `5002` signals session expiration to frontends
87+
- AES + PBKDF2 encryption for password handling (`config.encryption`)
88+
- Firebase integration for push notifications (`config.firebase`)
89+
- Quartz scheduler for background jobs (`config.quartz`)
90+
- Extensive test coverage with unit tests under `src/test/`
91+
92+
## CI/CD
93+
94+
- GitHub Actions: `package.yml`, `build-on-pull-request.yml`, `sast.yml`, `commit-lint.yml`, `codeql.yml`
95+
- Conventional Commits enforced via Husky + commitlint
96+
- Checkstyle configuration in `checkstyle.xml`
97+
- JaCoCo for code coverage, SonarQube integration configured
98+
- Dockerfile for containerized deployment

pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@
5454
</repository>
5555
</repositories>
5656
<dependencies>
57-
58-
<dependency>
59-
<groupId>com.h2database</groupId>
60-
<artifactId>h2</artifactId>
61-
<scope>runtime</scope>
62-
</dependency>
6357

6458
<dependency>
6559
<groupId>org.springframework.boot</groupId>

src/main/environment/common_ci.properties

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,19 @@ captcha.enable-captcha=@env.ENABLE_CAPTCHA@
190190

191191
cors.allowed-origins=@env.CORS_ALLOWED_ORIGINS@
192192

193-
video-call-url=@env.VIDEO_CALL_URL@
194-
jibri.output.path=@env.JIBRI_OUTPUT_PATH@
193+
# Jitsi configuration
194+
videocall.url=@env.VIDEO_CALL_URL@
195195
video.recording.path=@env.VIDEO_RECORDING_PATH@
196196

197+
# Jitsi JWT (prosody token-auth)
198+
jitsi.app.id=@env.JITSI_APP_ID@
199+
jitsi.app.secret=@env.JITSI_APP_SECRET@
200+
jitsi.domain=@env.JITSI_DOMAIN@
201+
jitsi.sub=@env.JITSI_SUB@
202+
jitsi.token.ttl.seconds=@env.JITSI_TOKEN_TTL_SECONDS@
203+
jitsi.room.prefix=@env.JITSI_ROOM_PREFIX@
204+
jitsi.default.user.email=@env.JITSI_DEFAULT_USER_EMAIL@
205+
197206
platform.feedback.ratelimit.enabled=@env.PLATFORM_FEEDBACK_RATELIMIT_ENABLED@
198207
platform.feedback.ratelimit.pepper=@env.PLATFORM_FEEDBACK_RATELIMIT_PEPPER@
199208
platform.feedback.ratelimit.trust-forwarded-for=@env.PLATFORM_FEEDBACK_RATELIMIT_TRUST_FORWARDED_FOR@

src/main/environment/common_docker.properties

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,18 @@ firebase.enabled=${FIREBASE_ENABLE}
192192
firebase.credential-file=${FIREBASE_CREDENTIAL}
193193

194194

195-
video-call-url=${VIDEO_CALL_URL}
196-
jibri.output.path={JIBRI_OUTPUT_PATH}
195+
videocall.url=${VIDEO_CALL_URL}
197196
video.recording.path={VIDEO_RECORDING_PATH}
198197

198+
# Jitsi JWT (prosody token-auth)
199+
jitsi.app.id=${JITSI_APP_ID}
200+
jitsi.app.secret=${JITSI_APP_SECRET}
201+
jitsi.domain=${JITSI_DOMAIN}
202+
jitsi.sub=${JITSI_SUB}
203+
jitsi.token.ttl.seconds=${JITSI_TOKEN_TTL_SECONDS}
204+
jitsi.room.prefix=${JITSI_ROOM_PREFIX}
205+
jitsi.default.user.email=${JITSI_DEFAULT_USER_EMAIL}
206+
199207
# Platform Feedback module
200208
platform.feedback.ratelimit.enabled=${PLATFORM_FEEDBACK_RATELIMIT_ENABLED}
201209
platform.feedback.ratelimit.pepper=${PLATFORM_FEEDBACK_RATELIMIT_PEPPER}

src/main/environment/common_example.properties

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ km-root-path=/okm:personal/users/
2525
km-guest-user=guest
2626
km-guest-password=guest
2727

28-
tempFilePath=/opt/openkm
28+
tempFilePath=/tmp
2929

3030
# CTI Config
3131
cti-server-ip=10.208.122.99
@@ -200,9 +200,9 @@ grievanceAllocationRetryConfiguration=3
200200
logging.path=logs/
201201
logging.file.name=logs/common-api.log
202202

203-
video-call-url=https://vc.piramalswasthya.org/?
204-
jibri.output.path=/srv/jibri/recordings
205-
video.recording.path=/srv/recordings
203+
# Jitsi configuration
204+
videocall.url=https://vc.piramalswasthya.org/?
205+
video.recording.path=/opt/recordings
206206

207207
captcha.secret-key= <Enter Cloudflare Secret Key>
208208
captcha.verify-url= https://challenges.cloudflare.com/turnstile/v0/siteverify
@@ -233,3 +233,11 @@ otp.ratelimit.day-limit=20
233233

234234
### generate Beneficiary IDs URL
235235
generateBeneficiaryIDs-api-url=/generateBeneficiaryController/generateBeneficiaryIDs
236+
237+
JITSI_APP_ID=piramal_vc
238+
JITSI_APP_SECRET=5b9883418be6f228ffe3ceaa74dd3d3b91737733a4a85c5e82fc584ad449850b
239+
JITSI_DOMAIN=vc.piramalswasthya.org
240+
JITSI_SUB=meet.jitsi
241+
JITSI_TOKEN_TTL_SECONDS=3600
242+
JITSI_ROOM_PREFIX=piramal-meeting-
243+
JITSI_DEFAULT_USER_EMAIL=admin@piramalswasthya.org

src/main/java/com/iemr/common/CommonApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.springframework.data.redis.connection.RedisConnectionFactory;
3030
import org.springframework.data.redis.core.RedisTemplate;
3131
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
32+
import org.springframework.scheduling.annotation.EnableAsync;
3233
import org.springframework.scheduling.annotation.EnableScheduling;
3334
import org.springframework.web.client.RestTemplate;
3435

@@ -40,6 +41,7 @@
4041

4142
@SpringBootApplication
4243
@EnableScheduling
44+
@EnableAsync(proxyTargetClass = true)
4345
public class CommonApplication extends SpringBootServletInitializer {
4446

4547
@Bean

src/main/java/com/iemr/common/config/InterceptorConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public class InterceptorConfig implements WebMvcConfigurer {
3636

3737
@Override
3838
public void addInterceptors(InterceptorRegistry registry) {
39-
registry.addInterceptor(requestInterceptor);
39+
registry.addInterceptor(requestInterceptor)
40+
.excludePathPatterns("/video-consultation/resolve", "**/video-consultation/resolve");
4041
}
4142

4243
}

src/main/java/com/iemr/common/config/encryption/SecurePassword.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@
2626
import java.security.NoSuchAlgorithmException;
2727
import java.security.SecureRandom;
2828
import java.security.spec.InvalidKeySpecException;
29-
3029
import javax.crypto.SecretKeyFactory;
3130
import javax.crypto.spec.PBEKeySpec;
32-
3331
import org.springframework.stereotype.Service;
3432

3533
@Service

src/main/java/com/iemr/common/controller/dynamicForm/DynamicFormController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,6 @@ public ResponseEntity<ApiResponse<?>> getStructuredForm(@PathVariable String for
9797
}
9898

9999

100+
101+
100102
}

src/main/java/com/iemr/common/controller/videocall/VideoCallController.java

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1+
/*
2+
* AMRIT – Accessible Medical Records via Integrated Technology
3+
* Integrated EHR (Electronic Health Records) Solution
4+
*
5+
* Copyright (C) "Piramal Swasthya Management and Research Institute"
6+
*
7+
* This file is part of AMRIT.
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License as published by
11+
* the Free Software Foundation, either version 3 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program. If not, see https://www.gnu.org/licenses/.
21+
*/
22+
123
package com.iemr.common.controller.videocall;
224

25+
import java.net.URI;
326
import java.util.HashMap;
427
import java.util.Map;
528

@@ -12,19 +35,19 @@
1235
import org.springframework.http.ResponseEntity;
1336
import org.springframework.web.bind.annotation.GetMapping;
1437
import org.springframework.web.bind.annotation.PostMapping;
38+
import org.springframework.web.bind.annotation.RequestBody;
1539
import org.springframework.web.bind.annotation.RequestMapping;
40+
import org.springframework.web.bind.annotation.RequestParam;
1641
import org.springframework.web.bind.annotation.RestController;
1742

43+
import com.fasterxml.jackson.databind.DeserializationFeature;
44+
import com.fasterxml.jackson.databind.ObjectMapper;
1845
import com.iemr.common.model.videocall.UpdateCallRequest;
1946
import com.iemr.common.model.videocall.VideoCallRequest;
2047
import com.iemr.common.service.videocall.VideoCallService;
2148
import com.iemr.common.utils.response.OutputResponse;
22-
import com.fasterxml.jackson.databind.SerializationFeature;
23-
import com.fasterxml.jackson.databind.DeserializationFeature;
24-
import com.fasterxml.jackson.databind.ObjectMapper;
25-
import jakarta.servlet.http.HttpServletRequest;
2649

27-
import org.springframework.web.bind.annotation.RequestBody;
50+
import jakarta.servlet.http.HttpServletRequest;
2851

2952
@RestController
3053
@RequestMapping(value = "/video-consultation")
@@ -67,32 +90,75 @@ public String sendVideoLink(@RequestBody String requestModel, HttpServletRequest
6790
}
6891

6992
@PostMapping(value = "/update-call-status", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
70-
public ResponseEntity<String> updateCallStatus(@RequestBody UpdateCallRequest requestModel, HttpServletRequest request) {
93+
public ResponseEntity<String> updateCallStatus(@RequestBody UpdateCallRequest requestModel,
94+
HttpServletRequest request) {
7195
OutputResponse response = new OutputResponse();
96+
logger.info("[updateCallStatus CONTROLLER] Received — meetingLink={}, callStatus={}, callDuration={}, modifiedBy={}, isLinkUsed={}",
97+
requestModel.getMeetingLink(),
98+
requestModel.getCallStatus(),
99+
requestModel.getCallDuration(),
100+
requestModel.getModifiedBy(),
101+
requestModel.getIsLinkUsed());
72102

73103
try {
74104
if (requestModel.getMeetingLink() == null || requestModel.getCallStatus() == null) {
105+
logger.error("[updateCallStatus CONTROLLER] Validation failed — meetingLink or callStatus is null");
75106
throw new IllegalArgumentException("Meeting Link and Status are required");
76107
}
77108

78109
String result = videoCallService.updateCallStatus(requestModel);
110+
logger.info("[updateCallStatus CONTROLLER] Service returned successfully");
79111

80112
JSONObject responseObj = new JSONObject();
81113
responseObj.put("status", "success");
82114
responseObj.put("message", result);
83115
response.setResponse(responseObj.toString());
84116

85117
} catch (IllegalArgumentException e) {
86-
logger.error("Validation error: " + e.getMessage(), e);
87-
return ResponseEntity.badRequest().body("{\"status\":\"error\",\"message\":\"" + e.getMessage() + "\"}");
118+
logger.error("[updateCallStatus CONTROLLER] Validation error: {}", e.getMessage(), e);
119+
return ResponseEntity.badRequest()
120+
.body("{\"status\":\"error\",\"message\":\"" + e.getMessage() + "\"}");
88121
} catch (Exception e) {
89-
logger.error("updateCallStatus failed with error: " + e.getMessage(), e);
122+
logger.error("[updateCallStatus CONTROLLER] Unexpected error: {}", e.getMessage(), e);
90123
response.setError(e);
91124
}
92125

93126
return ResponseEntity.ok(response.toString());
94127
}
95128

129+
/**
130+
* Public redirect endpoint hit when a beneficiary clicks the short SMS link.
131+
*
132+
* Flow:
133+
* 1. Jitsi host nginx receives "https://vc.piramalswasthya.org/?m=&lt;slug&gt;"
134+
* and proxies/redirects it to this endpoint.
135+
* 2. This endpoint looks up the slug, mints a fresh Jitsi JWT bound to the
136+
* room and the agent, and 302-redirects the browser to the full Jitsi URL
137+
* "https://vc.piramalswasthya.org/&lt;room&gt;?jwt=&lt;token&gt;".
138+
* 3. The Jitsi server enforces the JWT (prosody token-auth) and admits the user.
139+
*
140+
* Intentionally NOT guarded by Authorization header - the SMS recipient is on
141+
* a phone browser and has no app session. Access control is the JWT itself
142+
* plus the slug being unguessable and the meeting row existing.
143+
*/
144+
@GetMapping(value = "/resolve")
145+
public ResponseEntity<Void> resolveMeetingLink(@RequestParam("m") String slug) {
146+
try {
147+
String redirectUrl = videoCallService.resolveMeetingLink(slug);
148+
return ResponseEntity.status(HttpStatus.FOUND)
149+
.location(URI.create(redirectUrl))
150+
.build();
151+
} catch (IllegalArgumentException e) {
152+
logger.warn("resolveMeetingLink rejected: {}", e.getMessage());
153+
return ResponseEntity.badRequest().build();
154+
} catch (Exception e) {
155+
logger.error("resolveMeetingLink failed for slug={}: {}", slug, e.getMessage(), e);
96156

97-
157+
// Distinguish "link expired" from "not found" with a 410 Gone
158+
if (e.getMessage() != null && e.getMessage().contains("already been used")) {
159+
return ResponseEntity.status(HttpStatus.GONE).build(); // 410
160+
}
161+
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
162+
}
163+
}
98164
}

0 commit comments

Comments
 (0)