v0.5. Basic project data handling and forward validation

This commit is contained in:
Erik Eckert 2023-12-20 16:25:19 -07:00
parent 4e8e3e1026
commit 1dce4a6701
5 changed files with 876 additions and 19 deletions

18
.vscode/launch.json vendored
View File

@ -2,20 +2,20 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "Go Debug - Local", "name": "Go Debug - Docker - Local",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${file}",
"args": []
},
{
"name": "Go Debug - Docker",
"type": "go", "type": "go",
"request": "attach", "request": "attach",
"mode": "remote", "mode": "remote",
"port": 4000, "port": 4000,
"host": "127.0.0.1" "host": "127.0.0.1"
},
{
"name": "Go Debug - Docker - Remote",
"type": "go",
"request": "attach",
"mode": "remote",
"port": 4000,
"host": "192.168.2.55"
} }
] ]
} }

View File

@ -1,9 +1,10 @@
FROM golang:alpine FROM golang:alpine
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 10000
COPY main.go ./ COPY ./main/* ./
ENV GO111MODULE=off RUN go get -d github.com/gorilla/mux@latest
RUN go build -o hello-app . RUN go mod tidy
RUN go build -o mpe_mux_router .
CMD [ "./hello-app" ] CMD [ "./mpe_mux_router" ]

View File

@ -0,0 +1,721 @@
[
{
"eventId": "94adcf35-6d15-49fe-bef6-80bcf9d9f535",
"domain": "mpe",
"timestamp": 1702568374871,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Design Calculations"
}
}
]
[
{
"eventId": "fb9f9a81-d562-40ba-8382-1e09ade9b65c",
"domain": "mpe",
"timestamp": 1702568376925,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Tender Results"
}
}
]
[
{
"eventId": "4a4c0649-63e6-4a95-906d-bc1669f1b6bf",
"domain": "mpe",
"timestamp": 1702568376316,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Reports/Final Reports"
}
}
]
[
{
"eventId": "d5239467-befd-4b6b-85ed-aaebcb04e910",
"domain": "mpe",
"timestamp": 1702568375058,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Design Calculations/Final"
}
}
]
[
{
"eventId": "6d916860-14ec-49ec-9365-9e18c8ac79ff",
"domain": "mpe",
"timestamp": 1702568376401,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Reports/Preliminary Reports"
}
}
]
[
{
"eventId": "e7ce155c-82d8-4094-9b58-b9c2b2294fc4",
"domain": "mpe",
"timestamp": 1702568375363,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Minutes of Meeting"
}
}
]
[
{
"eventId": "1ee4144a-0a5d-473a-b1ac-72c2c1fb5499",
"domain": "mpe",
"timestamp": 1702568376105,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Quality Assurance/Soil"
}
}
]
[
{
"eventId": "9fab636b-e6f6-4657-af43-f4509afd2fca",
"domain": "mpe",
"timestamp": 1702568375574,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Progress Certificates"
}
}
]
[
{
"eventId": "79651735-424f-44d1-8d98-cbb8f0abb8ae",
"domain": "mpe",
"timestamp": 1702568376506,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Safety"
}
}
]
[
{
"eventId": "55e2d06d-d2ab-4783-b084-aeb84c0f6386",
"domain": "mpe",
"timestamp": 1702568375256,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/ExternalShare"
}
}
]
[
{
"eventId": "b7bc199e-666b-4dc3-b672-81cc64230cb1",
"domain": "mpe",
"timestamp": 1702568376767,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Surveys/Survey Forms"
}
}
]
[
{
"eventId": "0b7d16c7-b1d6-4a2f-8546-a3d4c0f3ef8d",
"domain": "mpe",
"timestamp": 1702568376680,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Surveys"
}
}
]
[
{
"eventId": "d73b7ac1-23ec-4253-974f-d791f775a86a",
"domain": "mpe",
"timestamp": 1702568376598,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Specifications"
}
}
]
[
{
"eventId": "d67f6a1f-baaf-4af3-ac2d-596bfd9e7158",
"domain": "mpe",
"timestamp": 1702568376208,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Reports"
}
}
]
[
{
"eventId": "bd18347f-090d-4338-9cac-92fdb7937246",
"domain": "mpe",
"timestamp": 1702568376847,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Surveys/Uploads"
}
}
]
[
{
"eventId": "c3782d6b-e290-4d97-b0bd-c71cd8d3ed16",
"domain": "mpe",
"timestamp": 1702568375152,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Design Calculations/Preliminary"
}
}
]
[
{
"eventId": "60a75929-4393-4b5e-a650-de29d06026c6",
"domain": "mpe",
"timestamp": 1702568375467,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Photos"
}
}
]
[
{
"eventId": "75fedb64-3877-40c1-b9e5-2b1bedb266b2",
"domain": "mpe",
"timestamp": 1702568375756,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Quality Assurance"
}
}
]
[
{
"eventId": "64927c69-f319-48ba-9842-1d1590a151da",
"domain": "mpe",
"timestamp": 1702568375655,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Proposal"
}
}
]
[
{
"eventId": "a0e4016f-7a50-4b2e-b80d-4c0034939d7a",
"domain": "mpe",
"timestamp": 1702568376000,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Quality Assurance/Concrete"
}
}
]
[
{
"eventId": "117b68eb-645d-43ad-9ade-13aa58b24a2d",
"domain": "mpe",
"timestamp": 1702568375842,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Quality Assurance/Aggregate"
}
}
]
[
{
"eventId": "5aab43bd-e7b0-4068-a905-08dd16e8a5cf",
"domain": "mpe",
"timestamp": 1702568375924,
"user": {
"id": 416,
"clientIdHash": "D988AC0B-7E6F-4831-A1F8-D0CCF3B39325",
"displayName": "Erik Eckert",
"username": "eeckert@mpe",
"email": "eeckert@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD_SYNC",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/MPE_Dev_Testing/Project Setup - Copy - Copy/Quality Assurance/Asphalt"
}
}
]
[
{
"eventId": "cab5ec4b-4dbb-4c78-a71c-f48e16e157e2",
"domain": "mpe",
"timestamp": 1702576261783,
"user": {
"id": 172,
"clientIdHash": "2373989a-c8ee-4876-842e-cf55b94151ca",
"displayName": "Barry Anderson",
"username": "banderson@mpe",
"email": "banderson@mpe.ca",
"impersonatedBy": "mpeitadmin@mpe"
},
"actionSource": "SCACHE",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/N-Data/43/50 Rocky Mountain House/005-Town_of_Rocky_Mountain_House/03 - Airport Terminal Final design & Construction/Design Calculations/Structural/New folder"
}
}
]
[
{
"eventId": "5c7a47a3-59b6-4ce9-a7d9-26a3cd62c3f0",
"domain": "mpe",
"timestamp": 1702576263010,
"user": {
"id": 172,
"clientIdHash": "2373989a-c8ee-4876-842e-cf55b94151ca",
"displayName": "Barry Anderson",
"username": "banderson@mpe",
"email": "banderson@mpe.ca",
"impersonatedBy": "mpeitadmin@mpe"
},
"actionSource": "SCACHE",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:move_folder",
"data": {
"sourcePath": "/Shared/N-Data/43/50 Rocky Mountain House/005-Town_of_Rocky_Mountain_House/03 - Airport Terminal Final design & Construction/Design Calculations/Structural/New folder",
"targetPath": "/Shared/N-Data/43/50 Rocky Mountain House/005-Town_of_Rocky_Mountain_House/03 - Airport Terminal Final design & Construction/Design Calculations/Structural/Markups"
}
}
]
[
{
"eventId": "88f7e822-da67-41e2-b9bc-a1ccff1b2e78",
"domain": "mpe",
"timestamp": 1702576307552,
"user": {
"id": 138,
"clientIdHash": "2373989a-c8ee-4876-842e-cf55b94151ca",
"displayName": "Kyle Lohrenz",
"username": "klohrenz@mpe",
"email": "klohrenz@mpe.ca",
"impersonatedBy": "mpeitadmin@mpe"
},
"actionSource": "SCACHE",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/N-Data/17/14 Alberta Parks/032 Cypress Hills PP - Water Treatment Plant & Lift Stations Upgrade/Reports/Final Reports/WWLS/Cover"
}
}
]
[
{
"eventId": "e118685b-6d75-4318-9e6c-47083cf24665",
"domain": "mpe",
"timestamp": 1702576320849,
"user": {
"id": 150,
"clientIdHash": "2373989a-c8ee-4876-842e-cf55b94151ca",
"displayName": "Ife Oyedotun",
"username": "ioyedotun@mpe",
"email": "ioyedotun@mpe.ca",
"impersonatedBy": "mpeitadmin@mpe"
},
"actionSource": "SCACHE",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/N-Data/73/81 Public Works and Government Services Canada/001 Fire Safety Willow Cree/Specifications/For Tender Update/New folder"
}
}
]
[
{
"eventId": "19e562be-ce66-4739-b434-615af8ce38e7",
"domain": "mpe",
"timestamp": 1702576323830,
"user": {
"id": 150,
"clientIdHash": "2373989a-c8ee-4876-842e-cf55b94151ca",
"displayName": "Ife Oyedotun",
"username": "ioyedotun@mpe",
"email": "ioyedotun@mpe.ca",
"impersonatedBy": "mpeitadmin@mpe"
},
"actionSource": "SCACHE",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:move_folder",
"data": {
"sourcePath": "/Shared/N-Data/73/81 Public Works and Government Services Canada/001 Fire Safety Willow Cree/Specifications/For Tender Update/New folder",
"targetPath": "/Shared/N-Data/73/81 Public Works and Government Services Canada/001 Fire Safety Willow Cree/Specifications/For Tender Update/Archive"
}
}
]
[
{
"eventId": "a12bec08-b9e5-4a85-a9d9-253f20abd3c3",
"domain": "mpe",
"timestamp": 1702576328423,
"user": {
"id": 150,
"clientIdHash": "2373989a-c8ee-4876-842e-cf55b94151ca",
"displayName": "Ife Oyedotun",
"username": "ioyedotun@mpe",
"email": "ioyedotun@mpe.ca",
"impersonatedBy": "mpeitadmin@mpe"
},
"actionSource": "SCACHE",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:move_folder",
"data": {
"sourcePath": "/Shared/N-Data/73/81 Public Works and Government Services Canada/001 Fire Safety Willow Cree/Specifications/For Tender Update/Division 23",
"targetPath": "/Shared/N-Data/73/81 Public Works and Government Services Canada/001 Fire Safety Willow Cree/Specifications/For Tender Update/Archive/Division 23"
}
}
]
[
{
"eventId": "48ff30ac-f647-4ba2-b0c0-c781867f9c4b",
"domain": "mpe",
"timestamp": 1702576925172,
"user": {
"id": 462,
"clientIdHash": "62f2fc5d-5266-45fe-91a6-80778686a5ec",
"displayName": "Sandra Copeland",
"username": "scopeland@mpe",
"email": "scopeland@mpe.ca",
"impersonatedBy": "mpeitadmin@mpe"
},
"actionSource": "SCACHE",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/H-Human Resources/Edmonton/Current Employees/LAWRIE_2021_Ken Lawrie_EE#0370/Safety/Driver's Info/New folder"
}
}
]
[
{
"eventId": "db5ffa9d-a4fa-4bdd-b8fb-066c820f5f49",
"domain": "mpe",
"timestamp": 1702576935471,
"user": {
"id": 462,
"clientIdHash": "62f2fc5d-5266-45fe-91a6-80778686a5ec",
"displayName": "Sandra Copeland",
"username": "scopeland@mpe",
"email": "scopeland@mpe.ca",
"impersonatedBy": "mpeitadmin@mpe"
},
"actionSource": "SCACHE",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:move_folder",
"data": {
"sourcePath": "/Shared/H-Human Resources/Edmonton/Current Employees/LAWRIE_2021_Ken Lawrie_EE#0370/Safety/Driver's Info/New folder",
"targetPath": "/Shared/H-Human Resources/Edmonton/Current Employees/LAWRIE_2021_Ken Lawrie_EE#0370/Safety/Driver's Info/Expired"
}
}
]
[
{
"eventId": "dff5d5e2-2a6a-4a19-a37f-10336002bc47",
"domain": "mpe",
"timestamp": 1702577087392,
"user": {
"id": 138,
"clientIdHash": "2373989a-c8ee-4876-842e-cf55b94151ca",
"displayName": "Kyle Lohrenz",
"username": "klohrenz@mpe",
"email": "klohrenz@mpe.ca",
"impersonatedBy": "mpeitadmin@mpe"
},
"actionSource": "SCACHE",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/N-Data/17/14 Alberta Parks/032 Cypress Hills PP - Water Treatment Plant & Lift Stations Upgrade/Reports/Final Reports/WWLS/New folder"
}
}
]
[
{
"eventId": "9badf089-1db9-4b5c-becc-e79fe0138b35",
"domain": "mpe",
"timestamp": 1702577088385,
"user": {
"id": 138,
"clientIdHash": "2373989a-c8ee-4876-842e-cf55b94151ca",
"displayName": "Kyle Lohrenz",
"username": "klohrenz@mpe",
"email": "klohrenz@mpe.ca",
"impersonatedBy": "mpeitadmin@mpe"
},
"actionSource": "SCACHE",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:move_folder",
"data": {
"sourcePath": "/Shared/N-Data/17/14 Alberta Parks/032 Cypress Hills PP - Water Treatment Plant & Lift Stations Upgrade/Reports/Final Reports/WWLS/New folder",
"targetPath": "/Shared/N-Data/17/14 Alberta Parks/032 Cypress Hills PP - Water Treatment Plant & Lift Stations Upgrade/Reports/Final Reports/WWLS/Appendix A"
}
}
]
[
{
"eventId": "cb1105a6-3d6f-417c-be4a-b5339fff57ab",
"domain": "mpe",
"timestamp": 1702577232541,
"user": {
"id": 622,
"clientIdHash": "8E265BB8-F490-4601-B994-9C1E0D0993D1",
"displayName": "Ben Ong",
"username": "bong@mpe",
"email": "bong@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:add_folder",
"data": {
"targetPath": "/Shared/N-Data/22/25 Mountain View County/002 Twp Rd 292 and 2023 Long Patching/Progress Certificates/New folder"
}
}
]
[
{
"eventId": "0b51d81b-c4f9-40ed-bfe3-70e680c06d5b",
"domain": "mpe",
"timestamp": 1702577242307,
"user": {
"id": 622,
"clientIdHash": "8E265BB8-F490-4601-B994-9C1E0D0993D1",
"displayName": "Ben Ong",
"username": "bong@mpe",
"email": "bong@mpe.ca",
"impersonatedBy": null
},
"actionSource": "EGD",
"webhookId": "b2944d04-5b9d-4b76-9639-904d772c5248",
"eventType": "fs:move_folder",
"data": {
"sourcePath": "/Shared/N-Data/22/25 Mountain View County/002 Twp Rd 292 and 2023 Long Patching/Progress Certificates/New folder",
"targetPath": "/Shared/N-Data/22/25 Mountain View County/002 Twp Rd 292 and 2023 Long Patching/Progress Certificates/PC4(HB)"
}
}
]

View File

@ -1,4 +1,4 @@
docker build . --tag debug-image --file Dockerfile.debug docker build . --tag debug-image --file Dockerfile.debug
docker stop debug-server docker stop debug-server
docker rm debug-server docker rm debug-server
docker run -d --publish 10000:10000 --publish 4000:4000 --name debug-server debug-image docker run -d --publish 15054:10000 --publish 4000:4000 --name debug-server debug-image

View File

@ -1,20 +1,134 @@
package main package main
import ( import (
"encoding/json"
"fmt" "fmt"
"io" "io"
"log" "log"
"net/http" "net/http"
"path/filepath"
"regexp"
"strings"
"time" "time"
"github.com/gorilla/mux" "github.com/gorilla/mux"
) )
func readDataStream(resp http.ResponseWriter, request *http.Request) { func MPE_IsProject(input map[string]json.RawMessage) (projectnumber string, project_name string) {
reqBody, _ := io.ReadAll(request.Body) // this will attempt to extract a project number from the "targetpath" element. If it's able to determine a folder contains a project number, we'll return it.
// var jsonBody = json.NewDecoder(request.Body) var path_data map[string]json.RawMessage
fmt.Println(string(reqBody)) project_regex, _ := regexp.Compile(`(^[0-9]{1,3})`) // regex to match against
err := json.Unmarshal((input["data"]), &path_data)
if err != nil {
log.Fatal(err)
fmt.Println("oops")
return
}
path := string(path_data["targetPath"])
split_path, _ := filepath.Split(path)
split_path = filepath.Clean(split_path)
separated_path := strings.Split(split_path, "/") //turn this into an array (slice?) to parse
var sb strings.Builder
// iterate through the path_data map. We want to find all strings that start with a number.
for _, value := range separated_path {
matched := project_regex.MatchString(value)
// matched, err := regexp.MatchString(`(^[0-9]{1,3})`, value)
// if err != nil {
// log.Fatal(err)
// fmt.Println("oops")
// return "RegexError", "RegExError"
// }
if matched {
// if we match the Regex above, write values to SB. This will give us a string like "73|10 Office Of Somone|153 HelpMe|002 Phase 2"
sb.WriteString(value + "|")
}
} // end of loop
// now to assemble project number and project name from the resulting values...
project_text := sb.String()
project_slice := strings.Split(project_text, "|")
// first value should be a digit, if not this can't be a project
isProject, _ := regexp.MatchString(`(^[0-9])`, project_slice[0])
if isProject {
project_regex, _ := regexp.Compile(`(^[0-9]{1,3})`) // regex to match against
regex_tidy_string, _ := regexp.Compile(`[-_]+|^\s`) //regex to tidy up folder paths
client_section := regex_tidy_string.ReplaceAllString(project_slice[1], "") // remove fancy chars from Client Name
project_section := regex_tidy_string.ReplaceAllString(project_regex.ReplaceAllString(project_slice[2], ""), " ") // remove leading-digits
project_section_digits := strings.Split(regex_tidy_string.ReplaceAllString(project_slice[2], " "), " ") //split on space for MOST file folders...
sb.Reset() // reset string builder so I can use it again!
sb.WriteString(project_slice[0]) // 73
sb.WriteString(strings.Split(client_section, " ")[0] + "-") // 7310 -- Client Name
sb.WriteString(project_section_digits[0]) // 7310-10
// do we have a third section of the project number?
project_third := strings.Split(project_slice[3], " ")[0]
project_third_match, _ := regexp.MatchString(`(^[0-9]{1,3})`, project_third)
if project_third_match {
// if we have a third section, then add another section to the project number, and append to the project name
third_project_name := project_regex.ReplaceAllString(project_slice[3], "") // 7310-10-153
project_name = project_section + "-" + regex_tidy_string.ReplaceAllString(third_project_name, "") // remove project digits from beginning of string and append
project_third = regex_tidy_string.ReplaceAllString(project_third, " ")
sb.WriteString("-" + project_third)
} else {
project_name = project_section // remove project digits from beginning of string
}
projectnumber = sb.String() // I should now have a project number!
} else {
return "NotAProject", "NoPath"
}
return
}
func MPE_ValidateForward(in map[string]json.RawMessage) bool {
// decode targetPath data. Will return TRUE if the last section of the path contains "External Share" or "ExternalShare". This would indicate that we SHOULD forward this request onward.
var path_data map[string]json.RawMessage
err := json.Unmarshal((in["data"]), &path_data)
if err != nil {
log.Fatal(err)
fmt.Println("oops")
return false
}
path := string(path_data["targetPath"])
split_path, last := filepath.Split(path)
split_path = filepath.Clean(split_path)
matched, err := regexp.MatchString(`ExternalShare|External Share`, last)
return matched
}
func readDataStream(resp http.ResponseWriter, request *http.Request) {
// reqBody, _ := io.ReadAll(request.Body)
body_string, _ := io.ReadAll(request.Body)
var request_body map[string]json.RawMessage
err := json.Unmarshal(body_string, &request_body)
if err != nil {
log.Fatal(err)
fmt.Println("oops")
return
}
var MPE_ShouldFoward = MPE_ValidateForward(request_body)
var MPE_ProjectNumber, MPE_ProjectName = MPE_IsProject(request_body)
// TODO: Collect EventID, JSON Content, and return values into data object to be logged to screen. Validate data visually for a bit against "live" webhook data.
fmt.Println(MPE_ShouldFoward, MPE_ProjectNumber, MPE_ProjectName)
// TODO: Once Data validation / Struct is built, pass data off to next Webhook URL for processing.
} }
func HealthCheck(resp http.ResponseWriter, request *http.Request) { func HealthCheck(resp http.ResponseWriter, request *http.Request) {
@ -53,3 +167,24 @@ func main() {
fmt.Println("MPE x Egnyte x PowerApps - Mux Router starting: " + t) fmt.Println("MPE x Egnyte x PowerApps - Mux Router starting: " + t)
handleRequests() handleRequests()
} }
type send_data struct {
EventID string `json:"eventId"`
Domain string `json:"domain"`
Timestamp int64 `json:"timestamp"`
User struct {
ID int `json:"id"`
ClientIDHash string `json:"clientIdHash"`
DisplayName string `json:"displayName"`
Username string `json:"username"`
Email string `json:"email"`
ImpersonatedBy interface{} `json:"impersonatedBy"`
} `json:"user"`
ActionSource string `json:"actionSource"`
WebhookID string `json:"webhookId"`
EventType string `json:"eventType"`
Data struct {
SourcePath string `json:"sourcePath"`
TargetPath string `json:"targetPath"`
} `json:"data"`
}