added user varification to webmessage in admin and api
parent
996f7066e1
commit
cd94e31a98
|
@ -1,9 +1,12 @@
|
|||
FROM nginx:1.21.1
|
||||
|
||||
# remove the config
|
||||
# remove the default config
|
||||
RUN rm /etc/nginx/conf.d/default.conf && \
|
||||
rm /etc/nginx/nginx.conf && \
|
||||
mkdir -p /var/www/html/admin
|
||||
rm /etc/nginx/nginx.conf
|
||||
|
||||
# create new root folder
|
||||
# todo: share upload folder in admin with myems-api container on Docker
|
||||
RUN mkdir -p /var/www/html/admin
|
||||
|
||||
# copy the config and web codes
|
||||
COPY nginx.conf /etc/nginx/
|
||||
|
|
|
@ -1,6 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
app.controller('WebMessageController', function($scope, $timeout, $translate, $uibModal, WebMessageAnalysisService, toaster, SweetAlert) {
|
||||
app.controller('WebMessageController', function(
|
||||
$scope,
|
||||
$window,
|
||||
$timeout,
|
||||
$translate,
|
||||
$uibModal,
|
||||
WebMessageAnalysisService,
|
||||
toaster,
|
||||
SweetAlert) {
|
||||
$scope.cur_user = JSON.parse($window.localStorage.getItem("myems_admin_ui_current_user"));
|
||||
$scope.$on('handleBroadcastWebMessageOptionChanged', function (event, data) {
|
||||
if (angular.isDefined(data.load)) {
|
||||
$scope.tabledata = [];
|
||||
|
@ -32,7 +41,8 @@ app.controller('WebMessageController', function($scope, $timeout, $translate, $u
|
|||
|
||||
modalInstance.result.then(function(modifiedWebmessage) {
|
||||
modifiedWebmessage.status = "acknowledged";
|
||||
WebMessageAnalysisService.editWebMessage(modifiedWebmessage, function (response) {
|
||||
let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
|
||||
WebMessageAnalysisService.editWebMessage(modifiedWebmessage, headers, function (response) {
|
||||
if (angular.isDefined(response.status) && response.status === 200) {
|
||||
toaster.pop({
|
||||
type: "success",
|
||||
|
@ -70,7 +80,8 @@ app.controller('WebMessageController', function($scope, $timeout, $translate, $u
|
|||
},
|
||||
function(isConfirm) {
|
||||
if (isConfirm) {
|
||||
WebMessageAnalysisService.deleteWebMessage(webmessage, function (response) {
|
||||
let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
|
||||
WebMessageAnalysisService.deleteWebMessage(webmessage, headers, function (response) {
|
||||
if (angular.isDefined(response.status) && response.status === 204) {
|
||||
toaster.pop({
|
||||
type: "success",
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
app.controller('WebMessageOptionController', function($scope, $timeout,
|
||||
app.controller('WebMessageOptionController', function(
|
||||
$scope,
|
||||
$window,
|
||||
$timeout,
|
||||
WebMessageAnalysisService) {
|
||||
$scope.cur_user = JSON.parse($window.localStorage.getItem("myems_admin_ui_current_user"));
|
||||
$scope.daterange = {
|
||||
startDate: moment().subtract(7,'days'),
|
||||
endDate: moment()
|
||||
|
@ -36,7 +40,8 @@ app.controller('WebMessageOptionController', function($scope, $timeout,
|
|||
load: true,
|
||||
period:$scope.currentPeriod
|
||||
});
|
||||
WebMessageAnalysisService.getAnalysisResult(query, function (response) {
|
||||
let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
|
||||
WebMessageAnalysisService.getAnalysisResult(query, headers, function (response) {
|
||||
if (angular.isDefined(response.status) && response.status === 200) {
|
||||
$scope.$emit('handleEmitWebMessageOptionChanged', response.data);
|
||||
}
|
||||
|
|
|
@ -200,11 +200,14 @@ app.controller('LoginController', function (
|
|||
// web message alarm section start
|
||||
$scope.webmessages = [];
|
||||
$scope.getWebMessage = function () {
|
||||
WebMessageAnalysisService.getStatusNewResult(function (response) {
|
||||
if ($scope.cur_user != null && $scope.cur_user.uuid != null && $scope.cur_user.token != null) {
|
||||
let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
|
||||
WebMessageAnalysisService.getStatusNewResult(headers, function (response) {
|
||||
if (angular.isDefined(response.status) && response.status === 200) {
|
||||
$scope.webmessages = response.data;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// web message alarm section end
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
app.factory('WebMessageAnalysisService', function($http) {
|
||||
return {
|
||||
|
||||
getAnalysisResult: function(query,callback) {
|
||||
var base="webmessages";
|
||||
var url=base+"/from/"+query.datestart+"/to/"+query.dateend;
|
||||
$http.get(getAPI()+url)
|
||||
getAnalysisResult: function(query, headers, callback) {
|
||||
$http.get(getAPI()+"webmessages"+"/from/"+query.datestart+"/to/"+query.dateend, {headers})
|
||||
.then(function (response) {
|
||||
callback(response);
|
||||
}, function (response) {
|
||||
|
@ -13,9 +11,8 @@ app.factory('WebMessageAnalysisService', function($http) {
|
|||
});
|
||||
},
|
||||
|
||||
getStatusNewResult: function(callback) {
|
||||
var base="webmessagesnew";
|
||||
$http.get(getAPI()+base)
|
||||
getStatusNewResult: function(headers, callback) {
|
||||
$http.get(getAPI()+"webmessagesnew", {headers})
|
||||
.then(function (response) {
|
||||
callback(response);
|
||||
}, function (response) {
|
||||
|
@ -23,8 +20,8 @@ app.factory('WebMessageAnalysisService', function($http) {
|
|||
});
|
||||
},
|
||||
|
||||
editWebMessage: function(webmessage, callback) {
|
||||
$http.put(getAPI()+'webmessages/'+webmessage.id, {data:webmessage})
|
||||
editWebMessage: function(webmessage, headers, callback) {
|
||||
$http.put(getAPI()+'webmessages/'+webmessage.id, {data:webmessage}, {headers})
|
||||
.then(function (response) {
|
||||
callback(response);
|
||||
}, function (response) {
|
||||
|
@ -32,8 +29,8 @@ app.factory('WebMessageAnalysisService', function($http) {
|
|||
});
|
||||
},
|
||||
|
||||
deleteWebMessage: function(webmessage, callback) {
|
||||
$http.delete(getAPI()+'webmessages/'+webmessage.id)
|
||||
deleteWebMessage: function(webmessage, headers, callback) {
|
||||
$http.delete(getAPI()+'webmessages/'+webmessage.id, {headers})
|
||||
.then(function (response) {
|
||||
callback(response);
|
||||
}, function (response) {
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">{{'FDD.ID' | translate}}</th>
|
||||
<th class="text-center">{{'FDD.RECIPIENT_NAME' | translate}}</th>
|
||||
<th class="text-center">{{'FDD.TOPIC' | translate}}</th>
|
||||
<th data-sort-ignore="true" class="text-center">{{'FDD.ALARM_MESSAGE' | translate}}</th>
|
||||
<th class="text-center">{{'FDD.ALARM_TIME' | translate}}</th>
|
||||
|
@ -42,7 +41,6 @@
|
|||
<tbody>
|
||||
<tr ng-repeat="row in tabledata track by $index">
|
||||
<td class="text-center sm">{{ row.id }}</td>
|
||||
<td class="text-center sm">{{ row.user_display_name }}</td>
|
||||
<td class="text-center sm">{{ row.subject }}</td>
|
||||
<td class="text-center sm col-lg-3 col-md-3" title="{{row.message}}">{{ row.message.slice(0,50) }}
|
||||
<small ng-show="{{row.message.length > 50 }}">...</small>
|
||||
|
|
|
@ -4,14 +4,6 @@
|
|||
</div>
|
||||
<div class="modal-body">
|
||||
<form role="form" name="form_webmessage" novalidate class="form-horizontal">
|
||||
<div class="form-group"><label class="col-sm-4 control-label">{{'FDD.RECIPIENT_NAME' | translate}}</label>
|
||||
|
||||
<div class="col-sm-8"><input ng-model="webmessage.user_display_name" type="text" name="webmessagename" class="form-control" disabled required="">
|
||||
<div class="m-t-xs" ng-show="form_webmessage.webmessagename.$invalid && form_webmessage.webmessagename.$dirty">
|
||||
<small class="text-danger" ng-show="form_webmessage.webmessagename.$error.required">{{'SETTING.NOT_NULLABLE' | translate}}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group"><label class="col-sm-4 control-label">{{'FDD.TOPIC' | translate}}</label>
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
FROM python:3.9.6
|
||||
WORKDIR /code
|
||||
|
||||
# todo: share upload folder with admin container on Docker
|
||||
RUN mkdir -p /var/www/html/admin/upload
|
||||
|
||||
COPY . /code
|
||||
RUN pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||||
EXPOSE 8000
|
||||
|
|
|
@ -910,7 +910,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "6ab593bb7e48f22da551572b444b2095b02f7fd717681215c16866b18846c9e0c7c9a10b612d26e262d2100223197a3804daec0ace179623dcb3d3e0a3213dbe",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"description": "Login to get a valid token",
|
||||
"type": "text"
|
||||
}
|
||||
|
@ -940,7 +940,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "6ab593bb7e48f22da551572b444b2095b02f7fd717681215c16866b18846c9e0c7c9a10b612d26e262d2100223197a3804daec0ace179623dcb3d3e0a3213dbe",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"description": "Login to get a valid token",
|
||||
"type": "text"
|
||||
}
|
||||
|
@ -966,12 +966,14 @@
|
|||
{
|
||||
"key": "User_UUID",
|
||||
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||
"type": "text"
|
||||
"type": "text",
|
||||
"description": "Any admin users' UUID"
|
||||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "6b0622f8974b2e6f2d7a7470baf073b78bddffd4",
|
||||
"type": "text"
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
|
@ -980,7 +982,7 @@
|
|||
{
|
||||
"key": "file",
|
||||
"type": "file",
|
||||
"src": "/zh/myems/myems-doc/offlinemeters.xlsx"
|
||||
"src": "/D:/myems/myems/myems-normalization/offline_meter_data.xlsx"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1009,7 +1011,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "6ab593bb7e48f22da551572b444b2095b02f7fd717681215c16866b18846c9e0c7c9a10b612d26e262d2100223197a3804daec0ace179623dcb3d3e0a3213dbe",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"description": "Login to get a valid token",
|
||||
"type": "text"
|
||||
}
|
||||
|
@ -1040,19 +1042,19 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "6ab593bb7e48f22da551572b444b2095b02f7fd717681215c16866b18846c9e0c7c9a10b612d26e262d2100223197a3804daec0ace179623dcb3d3e0a3213dbe",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"description": "Login to get a valid token",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/costfiles/20/restore",
|
||||
"raw": "{{base_url}}/costfiles/2/restore",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"costfiles",
|
||||
"20",
|
||||
"2",
|
||||
"restore"
|
||||
]
|
||||
}
|
||||
|
@ -1828,7 +1830,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "592641a558bc1724c4b75bd80d7d37b9b6a441b9b2231e3a5b2843b1f1e4f6864608ca97c4db00c94012b3406bf0c45cf231b789d2f551c1d420aa4de09f75cd",
|
||||
"value": "14f2bb7378e6926c20b54bd48bd8618e4d78ece1f1658c946a7257eaa97d3149ecd6407a62a39f0f3a6ef6b65f19d63894f297ad5a58d7b597a547f8b8e2898c",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
|
@ -1900,7 +1902,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "592641a558bc1724c4b75bd80d7d37b9b6a441b9b2231e3a5b2843b1f1e4f6864608ca97c4db00c94012b3406bf0c45cf231b789d2f551c1d420aa4de09f75cd",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
|
@ -3408,7 +3410,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "d2506282920bd7f1fb5db68605324bd7b8c6c305d84dcd43d43edfba6908136c4e468eca553c72f0211b2ad44fedb71c2f5c901816e5de828fa21cfb88a2552e",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
|
@ -3419,7 +3421,7 @@
|
|||
{
|
||||
"key": "file",
|
||||
"type": "file",
|
||||
"src": "/zh/myems/myems-standards/ISO 50001-2018.pdf"
|
||||
"src": "/D:/myems/myems/myems-normalization/offline_meter_data.xlsx"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -3448,7 +3450,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "d2506282920bd7f1fb5db68605324bd7b8c6c305d84dcd43d43edfba6908136c4e468eca553c72f0211b2ad44fedb71c2f5c901816e5de828fa21cfb88a2552e",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"description": "Login to get a valid token",
|
||||
"type": "text"
|
||||
}
|
||||
|
@ -3479,7 +3481,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "d2506282920bd7f1fb5db68605324bd7b8c6c305d84dcd43d43edfba6908136c4e468eca553c72f0211b2ad44fedb71c2f5c901816e5de828fa21cfb88a2552e",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"description": "Login to get a valid token",
|
||||
"type": "text"
|
||||
}
|
||||
|
@ -3870,13 +3872,13 @@
|
|||
{
|
||||
"key": "User-UUID",
|
||||
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||
"description": "Update this value after login",
|
||||
"description": "Any users' UUID",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "02f93023a39c98e1d1bc9f5197a83dfc5ddc0d48",
|
||||
"description": "Update this value after login",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"description": "Login to get a valid token",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
|
@ -3915,13 +3917,13 @@
|
|||
{
|
||||
"key": "User-UUID",
|
||||
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||
"description": "Update this value after login",
|
||||
"description": "Any users' UUID",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "02f93023a39c98e1d1bc9f5197a83dfc5ddc0d48",
|
||||
"description": "Update this value after login",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"description": "Login to get a valid token",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
|
@ -3946,13 +3948,13 @@
|
|||
{
|
||||
"key": "User-UUID",
|
||||
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||
"description": "Update this value after login",
|
||||
"description": "Any users' UUID",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "02f93023a39c98e1d1bc9f5197a83dfc5ddc0d48",
|
||||
"description": "Update this value after login",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"description": "Login to get a valid token",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
|
@ -3988,13 +3990,13 @@
|
|||
{
|
||||
"key": "User-UUID",
|
||||
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||
"description": "Update this value after login",
|
||||
"description": "Any users' UUID",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "02f93023a39c98e1d1bc9f5197a83dfc5ddc0d48",
|
||||
"description": "Update this value after login",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"description": "Login to get a valid token",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
|
@ -4130,7 +4132,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "d2506282920bd7f1fb5db68605324bd7b8c6c305d84dcd43d43edfba6908136c4e468eca553c72f0211b2ad44fedb71c2f5c901816e5de828fa21cfb88a2552e",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"description": "Login to get a valid token",
|
||||
"type": "text"
|
||||
}
|
||||
|
@ -4160,7 +4162,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "d2506282920bd7f1fb5db68605324bd7b8c6c305d84dcd43d43edfba6908136c4e468eca553c72f0211b2ad44fedb71c2f5c901816e5de828fa21cfb88a2552e",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
|
@ -4186,12 +4188,14 @@
|
|||
{
|
||||
"key": "User_UUID",
|
||||
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||
"type": "text"
|
||||
"type": "text",
|
||||
"description": "Any admin users' UUID"
|
||||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "6b0622f8974b2e6f2d7a7470baf073b78bddffd4",
|
||||
"type": "text"
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
|
@ -4200,7 +4204,7 @@
|
|||
{
|
||||
"key": "file",
|
||||
"type": "file",
|
||||
"src": "/zh/myems/myems-doc/offlinemeters.xlsx"
|
||||
"src": "/D:/myems/myems/myems-normalization/offline_meter_data.xlsx"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -4229,7 +4233,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "d2506282920bd7f1fb5db68605324bd7b8c6c305d84dcd43d43edfba6908136c4e468eca553c72f0211b2ad44fedb71c2f5c901816e5de828fa21cfb88a2552e",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
|
@ -4260,7 +4264,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "d2506282920bd7f1fb5db68605324bd7b8c6c305d84dcd43d43edfba6908136c4e468eca553c72f0211b2ad44fedb71c2f5c901816e5de828fa21cfb88a2552e",
|
||||
"value": "aad10e8cd48a3b8719860fed577033098cbc6caeb1454986189b0018bb76c6abc3a0b0600d0bec2fefb2c9cc5147aab23f50c4a4c8a64aaad0b7e4a7054905b8",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
|
@ -7389,7 +7393,7 @@
|
|||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "14f2bb7378e6926c20b54bd48bd8618e4d78ece1f1658c946a7257eaa97d3149ecd6407a62a39f0f3a6ef6b65f19d63894f297ad5a58d7b597a547f8b8e2898c",
|
||||
"value": "24bb236244f26784fb1397344d926b4871e87a90096eae926a0e448396dbd3ff4a2f70f727089f025238cb47bdbccdc877ef4a50fad8f05a4e5100c5d3eb0d3c",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
|
@ -8046,21 +8050,34 @@
|
|||
"name": "Web Message",
|
||||
"item": [
|
||||
{
|
||||
"name": "GET Web Messages from Startdate to Enddate",
|
||||
"name": "GET Web Messages by Date Range",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"header": [
|
||||
{
|
||||
"key": "User-UUID",
|
||||
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||
"type": "text",
|
||||
"description": "Any admin users' UUID"
|
||||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "24bb236244f26784fb1397344d926b4871e87a90096eae926a0e448396dbd3ff4a2f70f727089f025238cb47bdbccdc877ef4a50fad8f05a4e5100c5d3eb0d3c",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/webmessages/from/2020-04-01/to/2020-05-01",
|
||||
"raw": "{{base_url}}/webmessages/from/2021-12-01/to/2021-12-31",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"webmessages",
|
||||
"from",
|
||||
"2020-04-01",
|
||||
"2021-12-01",
|
||||
"to",
|
||||
"2020-05-01"
|
||||
"2021-12-31"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
|
@ -8077,7 +8094,20 @@
|
|||
"name": "GET All New Web Messages",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"header": [
|
||||
{
|
||||
"key": "User-UUID",
|
||||
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||
"type": "text",
|
||||
"description": "Any admin users' UUID"
|
||||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "24bb236244f26784fb1397344d926b4871e87a90096eae926a0e448396dbd3ff4a2f70f727089f025238cb47bdbccdc877ef4a50fad8f05a4e5100c5d3eb0d3c",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/webmessagesnew",
|
||||
"host": [
|
||||
|
@ -8098,10 +8128,23 @@
|
|||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "GET an Web Message by ID",
|
||||
"name": "GET a Web Message by ID",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"header": [
|
||||
{
|
||||
"key": "User-UUID",
|
||||
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||
"type": "text",
|
||||
"description": "Any admin users' UUID"
|
||||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "24bb236244f26784fb1397344d926b4871e87a90096eae926a0e448396dbd3ff4a2f70f727089f025238cb47bdbccdc877ef4a50fad8f05a4e5100c5d3eb0d3c",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/webmessages/1",
|
||||
"host": [
|
||||
|
@ -8119,7 +8162,20 @@
|
|||
"name": "POST Create New Web Message TODO",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"header": [
|
||||
{
|
||||
"key": "User-UUID",
|
||||
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||
"type": "text",
|
||||
"description": "Any admin users' UUID"
|
||||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "24bb236244f26784fb1397344d926b4871e87a90096eae926a0e448396dbd3ff4a2f70f727089f025238cb47bdbccdc877ef4a50fad8f05a4e5100c5d3eb0d3c",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/webmessages",
|
||||
"host": [
|
||||
|
@ -8133,10 +8189,23 @@
|
|||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "PUT Update an Web Message",
|
||||
"name": "PUT Update an Web Message TODO",
|
||||
"request": {
|
||||
"method": "PUT",
|
||||
"header": [],
|
||||
"header": [
|
||||
{
|
||||
"key": "User-UUID",
|
||||
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||
"type": "text",
|
||||
"description": "Any admin users' UUID"
|
||||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "24bb236244f26784fb1397344d926b4871e87a90096eae926a0e448396dbd3ff4a2f70f727089f025238cb47bdbccdc877ef4a50fad8f05a4e5100c5d3eb0d3c",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"data\":{\"status\":\"acknowledged\", \"reply\":\"this is my reply\"}}"
|
||||
|
@ -8155,18 +8224,31 @@
|
|||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "DELETE an Web Message by ID",
|
||||
"name": "DELETE a Web Message by ID",
|
||||
"request": {
|
||||
"method": "DELETE",
|
||||
"header": [],
|
||||
"header": [
|
||||
{
|
||||
"key": "User-UUID",
|
||||
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||
"type": "text",
|
||||
"description": "Any admin users' UUID"
|
||||
},
|
||||
{
|
||||
"key": "Token",
|
||||
"value": "24bb236244f26784fb1397344d926b4871e87a90096eae926a0e448396dbd3ff4a2f70f727089f025238cb47bdbccdc877ef4a50fad8f05a4e5100c5d3eb0d3c",
|
||||
"type": "text",
|
||||
"description": "Login to get a valid token"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/webmessages/2",
|
||||
"raw": "{{base_url}}/webmessages/1",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"webmessages",
|
||||
"2"
|
||||
"1"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -2082,15 +2082,15 @@ Result in JSON
|
|||
| status | string | Status ('new', 'acknowledged', 'timeout') |
|
||||
| reply | string | User's Reply text, allow null |
|
||||
```bash
|
||||
curl -i -X GET {{base_url}}/webmessages/{id}
|
||||
curl -i -H "User-UUID: 793f1bb4-6e25-4242-8cdc-2f662b25484f" -H "Token: GET-TOKEN-AFTER-LOGIN" -X GET {{base_url}}/webmessages/{id}
|
||||
```
|
||||
* GET Web Messages from Startdate to Enddate
|
||||
```bash
|
||||
curl -i -X GET {{base_url}}/webmessages/from/{startdate}/to/{enddate}
|
||||
curl -i -H "User-UUID: 793f1bb4-6e25-4242-8cdc-2f662b25484f" -H "Token: GET-TOKEN-AFTER-LOGIN" -X GET {{base_url}}/webmessages/from/{startdate}/to/{enddate}
|
||||
```
|
||||
* GET New Web Messages
|
||||
```bash
|
||||
curl -i -X GET {{base_url}}/webmessagesnew
|
||||
curl -i -H "User-UUID: 793f1bb4-6e25-4242-8cdc-2f662b25484f" -H "Token: GET-TOKEN-AFTER-LOGIN" -X GET {{base_url}}/webmessagesnew
|
||||
```
|
||||
* DELETE a Web Message by ID
|
||||
```bash
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import falcon
|
||||
import json
|
||||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
import uuid
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import falcon
|
||||
import json
|
||||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
import base64
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import falcon
|
||||
import json
|
||||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
import uuid
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import falcon
|
||||
import json
|
||||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import falcon
|
||||
import json
|
||||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
import uuid
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import falcon
|
||||
import json
|
||||
import simplejson as json
|
||||
import mysql.connector
|
||||
import config
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
@ -46,35 +46,74 @@ class WebMessageCollection:
|
|||
raise falcon.HTTPError(falcon.HTTP_400,
|
||||
title='API.BAD_REQUEST',
|
||||
description='API.START_DATETIME_MUST_BE_EARLIER_THAN_END_DATETIME')
|
||||
# get user dict
|
||||
|
||||
# Verify User Session
|
||||
token = req.headers.get('TOKEN')
|
||||
user_uuid = req.headers.get('USER-UUID')
|
||||
if token is None:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.TOKEN_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||
if user_uuid is None:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.USER_UUID_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||
|
||||
cnx = mysql.connector.connect(**config.myems_user_db)
|
||||
cursor = cnx.cursor(dictionary=True)
|
||||
|
||||
query = (" SELECT id, display_name "
|
||||
" FROM tbl_users ")
|
||||
cursor.execute(query)
|
||||
rows_users = cursor.fetchall()
|
||||
query = (" SELECT utc_expires "
|
||||
" FROM tbl_sessions "
|
||||
" WHERE user_uuid = %s AND token = %s")
|
||||
cursor.execute(query, (user_uuid, token,))
|
||||
row = cursor.fetchone()
|
||||
|
||||
if row is None:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_SESSION_PLEASE_RE_LOGIN')
|
||||
else:
|
||||
utc_expires = row['utc_expires']
|
||||
if datetime.utcnow() > utc_expires:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.USER_SESSION_TIMEOUT')
|
||||
|
||||
cursor.execute(" SELECT id "
|
||||
" FROM tbl_users "
|
||||
" WHERE uuid = %s ",
|
||||
(user_uuid,))
|
||||
row = cursor.fetchone()
|
||||
if row is None:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_USER_PLEASE_RE_LOGIN')
|
||||
else:
|
||||
user_id = row['id']
|
||||
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
|
||||
user_dict = dict()
|
||||
if rows_users is not None and len(rows_users) > 0:
|
||||
for row in rows_users:
|
||||
user_dict[row['id']] = row['display_name']
|
||||
|
||||
# get web messages
|
||||
cnx = mysql.connector.connect(**config.myems_fdd_db)
|
||||
cursor = cnx.cursor()
|
||||
|
||||
query = (" SELECT id, user_id, subject, message, "
|
||||
query = (" SELECT id, subject, message, "
|
||||
" created_datetime_utc, status, reply "
|
||||
" FROM tbl_web_messages "
|
||||
" WHERE created_datetime_utc >= %s AND created_datetime_utc < %s "
|
||||
" WHERE user_id = %s AND "
|
||||
" created_datetime_utc >= %s AND created_datetime_utc < %s "
|
||||
" ORDER BY created_datetime_utc DESC ")
|
||||
cursor.execute(query, (start_datetime_utc, end_datetime_utc))
|
||||
cursor.execute(query, (user_id, start_datetime_utc, end_datetime_utc))
|
||||
rows = cursor.fetchall()
|
||||
|
||||
if cursor:
|
||||
|
@ -86,13 +125,11 @@ class WebMessageCollection:
|
|||
if rows is not None and len(rows) > 0:
|
||||
for row in rows:
|
||||
meta_result = {"id": row[0],
|
||||
"user_id": row[1],
|
||||
"user_display_name": user_dict.get(row[1], None),
|
||||
"subject": row[2],
|
||||
"message": row[3].replace("<br>", ""),
|
||||
"created_datetime": row[4].timestamp() * 1000 if isinstance(row[4], datetime) else None,
|
||||
"status": row[5],
|
||||
"reply": row[6]}
|
||||
"subject": row[1],
|
||||
"message": row[2].replace("<br>", ""),
|
||||
"created_datetime": row[3].timestamp() * 1000 if isinstance(row[4], datetime) else None,
|
||||
"status": row[4],
|
||||
"reply": row[5]}
|
||||
result.append(meta_result)
|
||||
|
||||
resp.text = json.dumps(result)
|
||||
|
@ -110,36 +147,74 @@ class WebMessageStatusNewCollection:
|
|||
|
||||
@staticmethod
|
||||
def on_get(req, resp):
|
||||
"""Handles GET requests"""
|
||||
# Verify User Session
|
||||
token = req.headers.get('TOKEN')
|
||||
user_uuid = req.headers.get('USER-UUID')
|
||||
if token is None:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.TOKEN_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||
if user_uuid is None:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.USER_UUID_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||
|
||||
# get user dict
|
||||
cnx = mysql.connector.connect(**config.myems_user_db)
|
||||
cursor = cnx.cursor(dictionary=True)
|
||||
|
||||
query = (" SELECT id, display_name "
|
||||
" FROM tbl_users ")
|
||||
cursor.execute(query)
|
||||
rows_users = cursor.fetchall()
|
||||
query = (" SELECT utc_expires "
|
||||
" FROM tbl_sessions "
|
||||
" WHERE user_uuid = %s AND token = %s")
|
||||
cursor.execute(query, (user_uuid, token,))
|
||||
row = cursor.fetchone()
|
||||
|
||||
if row is None:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_SESSION_PLEASE_RE_LOGIN')
|
||||
else:
|
||||
utc_expires = row['utc_expires']
|
||||
if datetime.utcnow() > utc_expires:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.USER_SESSION_TIMEOUT')
|
||||
|
||||
cursor.execute(" SELECT id "
|
||||
" FROM tbl_users "
|
||||
" WHERE uuid = %s ",
|
||||
(user_uuid,))
|
||||
row = cursor.fetchone()
|
||||
if row is None:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_USER_PLEASE_RE_LOGIN')
|
||||
else:
|
||||
user_id = row['id']
|
||||
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
|
||||
user_dict = dict()
|
||||
if rows_users is not None and len(rows_users) > 0:
|
||||
for row in rows_users:
|
||||
user_dict[row['id']] = row['display_name']
|
||||
|
||||
# get new web messages
|
||||
# get 'new' web messages
|
||||
cnx = mysql.connector.connect(**config.myems_fdd_db)
|
||||
cursor = cnx.cursor()
|
||||
|
||||
query = (" SELECT id, user_id, subject, message, "
|
||||
" created_datetime_utc, status "
|
||||
query = (" SELECT id, subject, message, "
|
||||
" created_datetime_utc, status, reply "
|
||||
" FROM tbl_web_messages "
|
||||
" WHERE status = %s "
|
||||
" WHERE user_id = %s AND "
|
||||
" status = %s "
|
||||
" ORDER BY created_datetime_utc DESC ")
|
||||
cursor.execute(query, ("new", ))
|
||||
cursor.execute(query, (user_id, 'new'))
|
||||
rows = cursor.fetchall()
|
||||
|
||||
if cursor:
|
||||
|
@ -151,12 +226,11 @@ class WebMessageStatusNewCollection:
|
|||
if rows is not None and len(rows) > 0:
|
||||
for row in rows:
|
||||
meta_result = {"id": row[0],
|
||||
"user_id": row[1],
|
||||
"user_display_name": user_dict.get(row[1], None),
|
||||
"subject": row[2],
|
||||
"message": row[3].replace("<br>", ""),
|
||||
"created_datetime": row[4].timestamp() * 1000 if isinstance(row[4], datetime) else None,
|
||||
"status": row[5]}
|
||||
"subject": row[1],
|
||||
"message": row[2].replace("<br>", ""),
|
||||
"created_datetime": row[3].timestamp() * 1000 if isinstance(row[4], datetime) else None,
|
||||
"status": row[4],
|
||||
"reply": row[5]}
|
||||
result.append(meta_result)
|
||||
|
||||
resp.text = json.dumps(result)
|
||||
|
@ -179,34 +253,72 @@ class WebMessageItem:
|
|||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_WEB_MESSAGE_ID')
|
||||
|
||||
# get user dict
|
||||
# Verify User Session
|
||||
token = req.headers.get('TOKEN')
|
||||
user_uuid = req.headers.get('USER-UUID')
|
||||
if token is None:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.TOKEN_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||
if user_uuid is None:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.USER_UUID_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||
|
||||
cnx = mysql.connector.connect(**config.myems_user_db)
|
||||
cursor = cnx.cursor(dictionary=True)
|
||||
|
||||
query = (" SELECT id, display_name "
|
||||
" FROM tbl_users ")
|
||||
cursor.execute(query)
|
||||
rows_users = cursor.fetchall()
|
||||
query = (" SELECT utc_expires "
|
||||
" FROM tbl_sessions "
|
||||
" WHERE user_uuid = %s AND token = %s")
|
||||
cursor.execute(query, (user_uuid, token,))
|
||||
row = cursor.fetchone()
|
||||
|
||||
if row is None:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_SESSION_PLEASE_RE_LOGIN')
|
||||
else:
|
||||
utc_expires = row['utc_expires']
|
||||
if datetime.utcnow() > utc_expires:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.USER_SESSION_TIMEOUT')
|
||||
|
||||
cursor.execute(" SELECT id "
|
||||
" FROM tbl_users "
|
||||
" WHERE uuid = %s ",
|
||||
(user_uuid,))
|
||||
row = cursor.fetchone()
|
||||
if row is None:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_USER_PLEASE_RE_LOGIN')
|
||||
else:
|
||||
user_id = row['id']
|
||||
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
|
||||
user_dict = dict()
|
||||
if rows_users is not None and len(rows_users) > 0:
|
||||
for row in rows_users:
|
||||
user_dict[row['id']] = row['display_name']
|
||||
|
||||
# get web message
|
||||
# get web message by id
|
||||
cnx = mysql.connector.connect(**config.myems_fdd_db)
|
||||
cursor = cnx.cursor()
|
||||
|
||||
query = (" SELECT id, user_id, subject, message, "
|
||||
query = (" SELECT id, subject, message, "
|
||||
" created_datetime_utc, status, reply "
|
||||
" FROM tbl_web_messages "
|
||||
" WHERE id = %s ")
|
||||
cursor.execute(query, (id_,))
|
||||
" WHERE id = %s AND user_id = %s "
|
||||
" ORDER BY created_datetime_utc DESC ")
|
||||
cursor.execute(query, (id_, user_id))
|
||||
row = cursor.fetchone()
|
||||
|
||||
if cursor:
|
||||
|
@ -219,13 +331,11 @@ class WebMessageItem:
|
|||
description='API.WEB_MESSAGE_NOT_FOUND')
|
||||
|
||||
meta_result = {"id": row[0],
|
||||
"user_id": row[1],
|
||||
"user_display_name": user_dict.get(row[1], None),
|
||||
"subject": row[2],
|
||||
"message": row[3].replace("<br>", ""),
|
||||
"created_datetime": row[4].timestamp() * 1000 if isinstance(row[4], datetime) else None,
|
||||
"status": row[5],
|
||||
"reply": row[6]}
|
||||
"subject": row[1],
|
||||
"message": row[2].replace("<br>", ""),
|
||||
"created_datetime": row[3].timestamp() * 1000 if isinstance(row[4], datetime) else None,
|
||||
"status": row[4],
|
||||
"reply": row[5]}
|
||||
|
||||
resp.text = json.dumps(meta_result)
|
||||
|
||||
|
@ -259,12 +369,68 @@ class WebMessageItem:
|
|||
description='API.INVALID_REPLY')
|
||||
reply = str.strip(new_values['data']['reply'])
|
||||
|
||||
# Verify User Session
|
||||
token = req.headers.get('TOKEN')
|
||||
user_uuid = req.headers.get('USER-UUID')
|
||||
if token is None:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.TOKEN_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||
if user_uuid is None:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.USER_UUID_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||
|
||||
cnx = mysql.connector.connect(**config.myems_user_db)
|
||||
cursor = cnx.cursor(dictionary=True)
|
||||
|
||||
query = (" SELECT utc_expires "
|
||||
" FROM tbl_sessions "
|
||||
" WHERE user_uuid = %s AND token = %s")
|
||||
cursor.execute(query, (user_uuid, token,))
|
||||
row = cursor.fetchone()
|
||||
|
||||
if row is None:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_SESSION_PLEASE_RE_LOGIN')
|
||||
else:
|
||||
utc_expires = row['utc_expires']
|
||||
if datetime.utcnow() > utc_expires:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.USER_SESSION_TIMEOUT')
|
||||
|
||||
cursor.execute(" SELECT id "
|
||||
" FROM tbl_users "
|
||||
" WHERE uuid = %s ",
|
||||
(user_uuid,))
|
||||
row = cursor.fetchone()
|
||||
if row is None:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_USER_PLEASE_RE_LOGIN')
|
||||
else:
|
||||
user_id = row['id']
|
||||
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
|
||||
cnx = mysql.connector.connect(**config.myems_fdd_db)
|
||||
cursor = cnx.cursor()
|
||||
|
||||
cursor.execute(" SELECT user_id "
|
||||
" FROM tbl_web_messages "
|
||||
" WHERE id = %s ", (id_,))
|
||||
" WHERE id = %s AND user_id = %s ", (id_, user_id))
|
||||
if cursor.fetchone() is None:
|
||||
cursor.close()
|
||||
cnx.disconnect()
|
||||
|
@ -291,12 +457,68 @@ class WebMessageItem:
|
|||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_WEB_MESSAGE_ID')
|
||||
|
||||
# Verify User Session
|
||||
token = req.headers.get('TOKEN')
|
||||
user_uuid = req.headers.get('USER-UUID')
|
||||
if token is None:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.TOKEN_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||
if user_uuid is None:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.USER_UUID_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||
|
||||
cnx = mysql.connector.connect(**config.myems_user_db)
|
||||
cursor = cnx.cursor(dictionary=True)
|
||||
|
||||
query = (" SELECT utc_expires "
|
||||
" FROM tbl_sessions "
|
||||
" WHERE user_uuid = %s AND token = %s")
|
||||
cursor.execute(query, (user_uuid, token,))
|
||||
row = cursor.fetchone()
|
||||
|
||||
if row is None:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_SESSION_PLEASE_RE_LOGIN')
|
||||
else:
|
||||
utc_expires = row['utc_expires']
|
||||
if datetime.utcnow() > utc_expires:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.USER_SESSION_TIMEOUT')
|
||||
|
||||
cursor.execute(" SELECT id "
|
||||
" FROM tbl_users "
|
||||
" WHERE uuid = %s ",
|
||||
(user_uuid,))
|
||||
row = cursor.fetchone()
|
||||
if row is None:
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_USER_PLEASE_RE_LOGIN')
|
||||
else:
|
||||
user_id = row['id']
|
||||
|
||||
if cursor:
|
||||
cursor.close()
|
||||
if cnx:
|
||||
cnx.disconnect()
|
||||
|
||||
cnx = mysql.connector.connect(**config.myems_fdd_db)
|
||||
cursor = cnx.cursor()
|
||||
|
||||
cursor.execute(" SELECT id "
|
||||
" FROM tbl_web_messages "
|
||||
" WHERE id = %s ", (id_,))
|
||||
" WHERE id = %s AND user_id = %s ", (id_, user_id))
|
||||
row = cursor.fetchone()
|
||||
|
||||
if row is None:
|
||||
|
|
|
@ -76,6 +76,7 @@ WORKING_DAY_START_TIME_LOCAL=00:00:00
|
|||
# must use the root folder of myems-admin web application
|
||||
# for example if you serve myems-admin at /var/www/html/admin
|
||||
# you should set the upload_path as below
|
||||
# todo: share upload folder with admin container on Docker
|
||||
UPLOAD_PATH=/var/www/html/admin/upload/
|
||||
|
||||
# main currency unit
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
FROM nginx:1.21.1
|
||||
|
||||
# remove the config
|
||||
# remove the default config
|
||||
RUN rm /etc/nginx/conf.d/default.conf && \
|
||||
rm /etc/nginx/nginx.conf && \
|
||||
mkdir -p /var/www/html/web
|
||||
|
||||
# create new root folder
|
||||
RUN mkdir -p /var/www/html/web
|
||||
|
||||
# Note: You should run 'npm run build' in the web direction to generate the production build.
|
||||
COPY nginx.conf /etc/nginx/
|
||||
|
|
Loading…
Reference in New Issue