Skip to content

Commit a5394df

Browse files
Merge pull request #234 from toarunmishra/fix_firebasebase64
Fix firebasebase64
2 parents 66c3702 + 9ff4061 commit a5394df

19 files changed

Lines changed: 627 additions & 43 deletions

src/main/environment/common_ci.properties

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ cron-scheduler-sms=0 0/1 * * * ? *
4444
firebase.enabled=@env.FIREBASE_ENABLE@
4545
# if using file
4646
firebase.credential-file=@env.FIREBASE_CREDENTIAL@
47-
# for CI/CD
48-
firebase.credential-base64=@env.CREDENTIAL_BASE64@
4947

5048
#### Email Configuration
5149
send-email=@env.SEND_EMAIL@
@@ -177,7 +175,7 @@ springdoc.swagger-ui.enabled=false
177175
isProduction=@env.IS_PRODUCTION@
178176
grievanceAllocationRetryConfiguration=3
179177

180-
start-grievancedatasync-scheduler=false
178+
start-grievancedatasync-scheduler=true
181179
cron-scheduler-grievancedatasync=0 0/2 * * * ?
182180

183181
captcha.secret-key=@env.CAPTCHA_SECRET_KEY@
@@ -186,5 +184,6 @@ captcha.enable-captcha=@env.ENABLE_CAPTCHA@
186184

187185
cors.allowed-origins=@env.CORS_ALLOWED_ORIGINS@
188186

189-
190-
187+
video-call-url=@env.VIDEO_CALL_URL@
188+
jibri.output.path=@env.JIBRI_OUTPUT_PATH@
189+
video.recording.path=@env.VIDEO_RECORDING_PATH@

src/main/environment/common_docker.properties

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,8 @@ cors.allowed-origins=${CORS_ALLOWED_ORIGINS}
184184
firebase.enabled=${FIREBASE_ENABLE}
185185
# if using file
186186
firebase.credential-file=${FIREBASE_CREDENTIAL}
187-
# for CI/CD
188-
firebase.credential-base64=${CREDENTIAL_BASE64}
187+
188+
189+
video-call-url=${VIDEO_CALL_URL}
190+
jibri.output.path={JIBRI_OUTPUT_PATH}
191+
video.recording.path={VIDEO_RECORDING_PATH}

src/main/environment/common_example.properties

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ cti-server-ip=10.208.122.99
3030
cti-logger_base_url=http://10.208.122.99/logger
3131

3232
# Identity Config
33-
identity-api-url = http://localhost:8094/
33+
identity-api-url = http://localhost:8094
3434
#Verify whether 1097 and identity are same?
35-
identity-1097-api-url = http://localhost:8095/
35+
identity-1097-api-url = http://localhost:8095
3636
##Generate Benificiary Config
37-
genben-api=http://localhost:8092/
37+
genben-api=http://localhost:8092
3838

3939
#### SMS Configuration
4040
send-sms=false
41-
sendSMSUrl = http://localhost:8080/sms/sendSMS
41+
sendSMSUrl = http://localhost:8083/sms/sendSMS
4242
source-address=AIDSHL
4343
sms-username=<Enter SMS username>
4444
sms-password=<Enter SMS password>
@@ -198,6 +198,10 @@ grievanceAllocationRetryConfiguration=3
198198
logging.path=logs/
199199
logging.file.name=logs/common-api.log
200200

201+
video-call-url=https://vc.piramalswasthya.org/
202+
jibri.output.path=/srv/jibri/recordings
203+
video.recording.path=/srv/recordings
204+
201205
captcha.secret-key= <Enter Cloudflare Secret Key>
202206
captcha.verify-url= https://challenges.cloudflare.com/turnstile/v0/siteverify
203207
captcha.enable-captcha=true

src/main/java/com/iemr/common/config/firebase/FirebaseMessagingConfig.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public class FirebaseMessagingConfig {
2222
@Value("${firebase.credential-file:}")
2323
private String firebaseCredentialFile;
2424

25-
@Value("${firebase.credential-base64:}")
26-
private String firebaseCredentialBase64;
2725

2826
@Bean
2927
public FirebaseMessaging firebaseMessaging() throws IOException {
@@ -33,10 +31,7 @@ public FirebaseMessaging firebaseMessaging() throws IOException {
3331

3432
GoogleCredentials credentials;
3533

36-
if (!firebaseCredentialBase64.isBlank()) {
37-
byte[] decoded = Base64.getDecoder().decode(firebaseCredentialBase64);
38-
credentials = GoogleCredentials.fromStream(new ByteArrayInputStream(decoded));
39-
} else if (!firebaseCredentialFile.isBlank()) {
34+
if (!firebaseCredentialFile.isBlank()) {
4035
credentials = GoogleCredentials.fromStream(
4136
new ClassPathResource(firebaseCredentialFile).getInputStream()
4237
);
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package com.iemr.common.controller.videocall;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
import org.json.JSONObject;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.http.HttpStatus;
11+
import org.springframework.http.MediaType;
12+
import org.springframework.http.ResponseEntity;
13+
import org.springframework.web.bind.annotation.GetMapping;
14+
import org.springframework.web.bind.annotation.PostMapping;
15+
import org.springframework.web.bind.annotation.RequestMapping;
16+
import org.springframework.web.bind.annotation.RestController;
17+
18+
import com.iemr.common.model.videocall.UpdateCallRequest;
19+
import com.iemr.common.model.videocall.VideoCallRequest;
20+
import com.iemr.common.service.videocall.VideoCallService;
21+
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;
26+
27+
import org.springframework.web.bind.annotation.RequestBody;
28+
29+
@RestController
30+
@RequestMapping(value = "/video-consultation")
31+
public class VideoCallController {
32+
final Logger logger = LoggerFactory.getLogger(this.getClass().getName());
33+
34+
@Autowired
35+
private VideoCallService videoCallService;
36+
37+
@PostMapping(value = "/generate-link", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
38+
public ResponseEntity<Map<String, String>> generateJitsiLink() {
39+
Map<String, String> response = new HashMap<>();
40+
try {
41+
String link = videoCallService.generateMeetingLink();
42+
response.put("meetingLink", link);
43+
return ResponseEntity.ok(response);
44+
} catch (Exception e) {
45+
response.put("error", e.getMessage());
46+
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
47+
}
48+
}
49+
50+
@PostMapping(value = "/send-link", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
51+
public String sendVideoLink(@RequestBody String requestModel, HttpServletRequest request) {
52+
OutputResponse response = new OutputResponse();
53+
54+
try {
55+
ObjectMapper objectMapper = new ObjectMapper();
56+
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
57+
VideoCallRequest requestData = objectMapper.readValue(requestModel, VideoCallRequest.class);
58+
String serviceResponse = videoCallService.sendMeetingLink(requestData);
59+
60+
return serviceResponse;
61+
62+
} catch (Exception e) {
63+
logger.error("send MeetingLink failed with error: " + e.getMessage(), e);
64+
response.setError(e);
65+
return response.toString();
66+
}
67+
}
68+
69+
@PostMapping(value = "/update-call-status", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
70+
public ResponseEntity<String> updateCallStatus(@RequestBody UpdateCallRequest requestModel, HttpServletRequest request) {
71+
OutputResponse response = new OutputResponse();
72+
73+
try {
74+
if (requestModel.getMeetingLink() == null || requestModel.getCallStatus() == null) {
75+
throw new IllegalArgumentException("Meeting Link and Status are required");
76+
}
77+
78+
String result = videoCallService.updateCallStatus(requestModel);
79+
80+
JSONObject responseObj = new JSONObject();
81+
responseObj.put("status", "success");
82+
responseObj.put("message", result);
83+
response.setResponse(responseObj.toString());
84+
85+
} catch (IllegalArgumentException e) {
86+
logger.error("Validation error: " + e.getMessage(), e);
87+
return ResponseEntity.badRequest().body("{\"status\":\"error\",\"message\":\"" + e.getMessage() + "\"}");
88+
} catch (Exception e) {
89+
logger.error("updateCallStatus failed with error: " + e.getMessage(), e);
90+
response.setError(e);
91+
}
92+
93+
return ResponseEntity.ok(response.toString());
94+
}
95+
96+
97+
98+
}

src/main/java/com/iemr/common/data/sms/SMSParametersMap.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import java.sql.Timestamp;
2525

2626
import com.iemr.common.utils.mapper.OutputMapper;
27-
27+
import com.google.gson.GsonBuilder;
28+
import com.google.gson.LongSerializationPolicy;
29+
import com.google.gson.annotations.Expose;
2830
import jakarta.persistence.Column;
2931
import jakarta.persistence.Entity;
3032
import jakarta.persistence.GeneratedValue;
@@ -69,9 +71,11 @@ public class SMSParametersMap
6971
@Column(name = "LastModDate", insertable = false, updatable = false)
7072
Timestamp lastModDate;
7173

72-
@Override
73-
public String toString()
74-
{
75-
return OutputMapper.gsonWithoutExposeRestriction().toJson(this);
74+
@Override
75+
public String toString() {
76+
77+
return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().setLongSerializationPolicy(LongSerializationPolicy.STRING).serializeNulls()
78+
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create().toJson(this);
7679
}
80+
7781
}

src/main/java/com/iemr/common/data/sms/SMSTemplate.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
import com.iemr.common.utils.mapper.OutputMapper;
2828

29+
import com.google.gson.GsonBuilder;
30+
import com.google.gson.LongSerializationPolicy;
2931
import jakarta.persistence.Column;
3032
import jakarta.persistence.Entity;
3133
import jakarta.persistence.FetchType;
@@ -77,8 +79,10 @@ public class SMSTemplate
7779
Timestamp lastModDate;
7880

7981
@Override
80-
public String toString()
81-
{
82-
return OutputMapper.gsonWithoutExposeRestriction().toJson(this);
82+
public String toString() {
83+
84+
return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().setLongSerializationPolicy(LongSerializationPolicy.STRING).serializeNulls()
85+
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create().toJson(this);
8386
}
87+
8488
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.iemr.common.data.videocall;
2+
3+
import java.sql.Timestamp;
4+
5+
import com.iemr.common.utils.mapper.OutputMapper;
6+
7+
import jakarta.persistence.Column;
8+
import jakarta.persistence.Entity;
9+
import jakarta.persistence.GeneratedValue;
10+
import jakarta.persistence.GenerationType;
11+
import jakarta.persistence.Id;
12+
import jakarta.persistence.Table;
13+
import lombok.Data;
14+
15+
@Entity
16+
@Table(name = "t_videocallparameter")
17+
@Data
18+
public class VideoCallParameters {
19+
@Id
20+
@GeneratedValue(strategy = GenerationType.IDENTITY)
21+
@Column(name = "MeetingID")
22+
private Integer meetingID;
23+
24+
@Column(name = "DateOfCall")
25+
private Timestamp dateOfCall;
26+
27+
@Column(name = "CallerPhoneNumber")
28+
private String callerPhoneNumber;
29+
30+
@Column(name = "AgentID")
31+
private String agentID;
32+
33+
@Column(name = "AgentName")
34+
private String agentName;
35+
36+
@Column(name = "MeetingLink")
37+
private String meetingLink;
38+
39+
@Column(name = "CallStatus")
40+
private String callStatus;
41+
42+
@Column(name = "CallDuration")
43+
private String callDuration;
44+
45+
@Column(name = "ProviderServiceMapID")
46+
private Integer providerServiceMapID;
47+
48+
@Column(name = "BeneficiaryRegID")
49+
private Long beneficiaryRegID;
50+
51+
@Column(name = "ClosureRemark")
52+
private String closureRemark;
53+
54+
@Column(name = "LinkGeneratedAt")
55+
private Timestamp linkGeneratedAt;
56+
57+
@Column(name = "IsLinkUsed")
58+
private boolean linkUsed;
59+
60+
@Column(name = "Deleted", insertable = false, updatable = true)
61+
private Boolean deleted;
62+
63+
@Column(name = "CreatedBy", insertable = true, updatable = false)
64+
private String createdBy;
65+
66+
@Column(name = "CreatedDate", insertable = false, updatable = false)
67+
private Timestamp createdDate;
68+
69+
@Column(name = "ModifiedBy", insertable = false, updatable = true)
70+
private String modifiedBy;
71+
72+
@Column(name = "LastModDate", insertable = false, updatable = false)
73+
private Timestamp lastModDate;
74+
75+
@Override
76+
public String toString()
77+
{
78+
return OutputMapper.gsonWithoutExposeRestriction().toJson(this);
79+
}
80+
}

src/main/java/com/iemr/common/mapper/sms/SMSMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public interface SMSMapper
4848

4949
SMSMapper INSTANCE = Mappers.getMapper(SMSMapper.class);
5050

51-
@Mappings({ @Mapping(source = "request.smsTemplateTypeID", target = "smsTypeID"), })
51+
@Mappings({ @Mapping(source = "request.smsTemplateTypeID", target = "smsTypeID") })
5252
SMSTemplate requestToSMSTemplate(SMSRequest request);
5353

5454
@IterableMapping(elementTargetType = SMSTemplate.class)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.iemr.common.mapper.videocall;
2+
3+
import java.util.List;
4+
import org.mapstruct.Mapper;
5+
import org.mapstruct.factory.Mappers;
6+
import org.mapstruct.IterableMapping;
7+
import org.mapstruct.factory.Mappers;
8+
9+
import com.iemr.common.data.videocall.VideoCallParameters;
10+
import com.iemr.common.model.videocall.UpdateCallRequest;
11+
import com.iemr.common.model.videocall.UpdateCallResponse;
12+
import com.iemr.common.model.videocall.VideoCallRequest;
13+
14+
@Mapper(componentModel = "spring")
15+
public interface VideoCallMapper {
16+
VideoCallMapper INSTANCE = Mappers.getMapper(VideoCallMapper.class);
17+
18+
VideoCallRequest videoCallToRequest(VideoCallParameters videoCall);
19+
20+
VideoCallParameters videoCallToEntity(VideoCallRequest videoCallRequest);
21+
22+
@IterableMapping(elementTargetType = VideoCallRequest.class)
23+
List<VideoCallRequest> videoCallToRequestList(List<VideoCallParameters> videoCallList);
24+
25+
@IterableMapping(elementTargetType = VideoCallParameters.class)
26+
List<VideoCallParameters> videoCallToEntityList(List<VideoCallRequest> videoCallRequestList);
27+
28+
VideoCallParameters updateRequestToVideoCall(UpdateCallRequest updateCallStatusRequest);
29+
30+
UpdateCallResponse videoCallToResponse(VideoCallParameters videoCall);
31+
32+
@IterableMapping(elementTargetType = VideoCallParameters.class)
33+
List<VideoCallParameters> updateRequestToVideoCall(List<UpdateCallRequest> updateCallStatusRequests);
34+
35+
@IterableMapping(elementTargetType = UpdateCallResponse.class)
36+
List<UpdateCallResponse> videoCallToResponse(List<VideoCallParameters> videoCalls);
37+
}

0 commit comments

Comments
 (0)