Bug Fixes and Sustainability added
This commit is contained in:
16
.env.production.example
Normal file
16
.env.production.example
Normal file
@@ -0,0 +1,16 @@
|
||||
# Database Configuration
|
||||
DB_URL=jdbc:postgresql://localhost:5432/IMS%20data
|
||||
DB_USERNAME=whatsapp_user
|
||||
DB_PASSWORD=RITHosting123
|
||||
SPRING_JPA_HIBERNATE_DDL_AUTO=update
|
||||
|
||||
# Server Configuration
|
||||
PORT=8080
|
||||
|
||||
# WhatsApp API Configuration
|
||||
WHATSAPP_PHONE_NUMBER_ID=1239246362613929
|
||||
WHATSAPP_API_TOKEN=EAAc3Wjql00oBSZAkH0ymUgZAJnxgkiPDfAKpvBQmfVZCVGZB3fZCED4pS9vGELKRqkCZC3lIkLbsEp0Qejhb1xJmWVvZArTGTTpZCXbwSUoN21cZAiKpkdw4uLrt2sR11UIy8p1ZBqVgFZB5Od9HfGVgvbWWBJSECEp7lq226Ap8UID3fHss7LsSgajxDEQWtxmy5NtsAZDZD
|
||||
WHATSAPP_VERIFY_TOKEN=rit_bot_secret_token_123
|
||||
|
||||
# Security & Encryption
|
||||
BOT_ENCRYPTION_SECRET=12345678901234567890123456789012
|
||||
@@ -22,6 +22,21 @@ public class UserEntity {
|
||||
@Column(name = "is_faculty", columnDefinition = "boolean default false")
|
||||
private Boolean isFaculty = false;
|
||||
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "year")
|
||||
private Integer year;
|
||||
|
||||
@Column(name = "department")
|
||||
private String department;
|
||||
|
||||
@Column(name = "section")
|
||||
private String section;
|
||||
|
||||
@Column(name = "email_id")
|
||||
private String emailId;
|
||||
|
||||
public UserEntity() {
|
||||
}
|
||||
|
||||
@@ -69,4 +84,44 @@ public class UserEntity {
|
||||
public void setFaculty(Boolean faculty) {
|
||||
isFaculty = faculty;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setYear(Integer year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public String getDepartment() {
|
||||
return department;
|
||||
}
|
||||
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
|
||||
public String getSection() {
|
||||
return section;
|
||||
}
|
||||
|
||||
public void setSection(String section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
public String getEmailId() {
|
||||
return emailId;
|
||||
}
|
||||
|
||||
public void setEmailId(String emailId) {
|
||||
this.emailId = emailId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,16 @@ public class SessionService {
|
||||
if (studentNames.containsKey(phoneNumber)) {
|
||||
return studentNames.get(phoneNumber);
|
||||
}
|
||||
|
||||
// Try getting name from database first
|
||||
Optional<UserEntity> userOpt = userRepository.findByPhoneNumber(phoneNumber);
|
||||
if (userOpt.isPresent() && userOpt.get().getName() != null && !userOpt.get().getName().isEmpty()) {
|
||||
String dbName = userOpt.get().getName();
|
||||
studentNames.put(phoneNumber, dbName);
|
||||
return dbName;
|
||||
}
|
||||
|
||||
// Fallback to IMS API
|
||||
String name;
|
||||
if (isFaculty(phoneNumber)) {
|
||||
name = imsApiService.getFacultyName(token);
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
spring.application.name=whatsapp-bot
|
||||
server.port=8080
|
||||
server.port=${PORT:8080}
|
||||
|
||||
# WhatsApp Verification Token (You provide this to Meta during webhook setup)
|
||||
whatsapp.verify-token=rit_bot_secret_token_123
|
||||
|
||||
# WhatsApp Graph API Token (You get this from the Meta developer console)
|
||||
# WhatsApp Phone Number ID (You get this from the Meta developer console)
|
||||
whatsapp.phone-number-id=1239246362613929
|
||||
whatsapp.verify-token=${WHATSAPP_VERIFY_TOKEN:rit_bot_secret_token_123}
|
||||
|
||||
# WhatsApp Graph API Token & Phone Number ID (You get these from the Meta developer console)
|
||||
whatsapp.phone-number-id=${WHATSAPP_PHONE_NUMBER_ID:1239246362613929}
|
||||
whatsapp.api-token=${WHATSAPP_API_TOKEN:EAAc3Wjql00oBSZAkH0ymUgZAJnxgkiPDfAKpvBQmfVZCVGZB3fZCED4pS9vGELKRqkCZC3lIkLbsEp0Qejhb1xJmWVvZArTGTTpZCXbwSUoN21cZAiKpkdw4uLrt2sR11UIy8p1ZBqVgFZB5Od9HfGVgvbWWBJSECEp7lq226Ap8UID3fHss7LsSgajxDEQWtxmy5NtsAZDZD}
|
||||
whatsapp.dev-webhook-forward-url=${WHATSAPP_DEV_WEBHOOK_FORWARD_URL:http://127.0.0.1:2336/webhook}
|
||||
|
||||
# PostgreSQL Database Configuration
|
||||
spring.datasource.url=${DB_URL}
|
||||
spring.datasource.url=${DB_URL:jdbc:postgresql://localhost:5432/IMS%20data}
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
spring.datasource.username=${DB_USERNAME}
|
||||
spring.datasource.password=${DB_PASSWORD}
|
||||
spring.datasource.username=${DB_USERNAME:whatsapp_user}
|
||||
spring.datasource.password=${DB_PASSWORD:RITHosting123}
|
||||
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.hibernate.ddl-auto=${SPRING_JPA_HIBERNATE_DDL_AUTO:update}
|
||||
|
||||
# Encryption Secret for Passcodes (Must be 16, 24, or 32 bytes)
|
||||
bot.encryption.secret=12345678901234567890123456789012
|
||||
whatsapp.api-token=EAAc3Wjql00oBSZAkH0ymUgZAJnxgkiPDfAKpvBQmfVZCVGZB3fZCED4pS9vGELKRqkCZC3lIkLbsEp0Qejhb1xJmWVvZArTGTTpZCXbwSUoN21cZAiKpkdw4uLrt2sR11UIy8p1ZBqVgFZB5Od9HfGVgvbWWBJSECEp7lq226Ap8UID3fHss7LsSgajxDEQWtxmy5NtsAZDZD
|
||||
whatsapp.dev-webhook-forward-url=http://127.0.0.1:2336/webhook
|
||||
bot.encryption.secret=${BOT_ENCRYPTION_SECRET:12345678901234567890123456789012}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user