Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
MPAI-MMM
mmm-tec
Commits
82275fe1
Commit
82275fe1
authored
Feb 21, 2025
by
cann-alberto
Browse files
Version for the MPAI Demo
parent
47234984
Changes
35
Hide whitespace changes
Inline
Side-by-side
MMM-Server/MMM-Server/Controllers/ActivityController.cs
View file @
82275fe1
...
...
@@ -9,17 +9,30 @@ namespace MMM_Server.Controllers;
public
class
ActivityController
:
ControllerBase
{
private
readonly
UserService
_usersService
;
private
readonly
ActionService
_actionsService
;
public
ActivityController
(
UserService
usersService
)
public
ActivityController
(
UserService
usersService
,
ActionService
actionService
)
{
_usersService
=
usersService
;
_actionsService
=
actionService
;
}
[
HttpGet
(
"
profile
s"
)]
[
HttpGet
(
"
user
s"
)]
public
async
Task
<
List
<
User
>>
Get
()
=>
await
_usersService
.
GetAsync
();
[
HttpGet
(
"actions"
)]
public
async
Task
<
List
<
ActionRequest
>>
GetActions
()
=>
await
_actionsService
.
GetAsync
();
[
HttpPost
(
"actions"
)]
public
async
Task
<
IActionResult
>
Post
(
ActionRequest
newAction
)
{
await
_actionsService
.
CreateAsync
(
newAction
);
return
CreatedAtAction
(
nameof
(
Get
),
new
{
id
=
newAction
.
ActionRequestID
},
newAction
);
}
}
...
...
MMM-Server/MMM-Server/Controllers/AuthorController.cs
View file @
82275fe1
namespace
MMM_Server.Controllers
;
using
Microsoft.AspNetCore.Mvc
;
using
MMM_Server.Models
;
using
MMM_Server.Services
;
public
class
AuthorController
namespace
MMM_Server.Controllers
;
[
ApiController
]
[
Route
(
"api/[controller]"
)]
public
class
AuthorController
:
ControllerBase
{
private
readonly
UserService
_usersService
;
public
AuthorController
(
UserService
usersService
)
{
_usersService
=
usersService
;
}
[
HttpGet
(
"users"
)]
public
async
Task
<
List
<
User
>>
Get
()
=>
await
_usersService
.
GetAsync
();
}
...
...
MMM-Server/MMM-Server/Controllers/RegistrationController.cs
View file @
82275fe1
...
...
@@ -39,13 +39,7 @@ public class RegistrationController : ControllerBase
{
// Insert the new profile in the DB
await
_personalProfilesService
.
CreateAsync
(
newPersonalProfile
);
// Insert the new account in the DB
//await _accountsService.CreateAsync(newAccount);
return
CreatedAtAction
(
nameof
(
Get
),
new
{
id
=
newPersonalProfile
.
PersonalProfileID
},
newPersonalProfile
);
}
...
...
@@ -73,6 +67,30 @@ public class RegistrationController : ControllerBase
return
CreatedAtAction
(
nameof
(
Get
),
new
{
id
=
newDevice
.
Id
},
newDevice
);
}
[
HttpGet
(
"accounts/{humanId}"
)]
public
async
Task
<
IActionResult
>
GetAccountByHumanId
(
string
humanId
)
{
try
{
// Call the service method to retrieve the account
var
account
=
await
_accountsService
.
GetByHumanIdAsync
(
humanId
);
if
(
account
==
null
)
{
// If no account is found, return a NotFound status
return
NotFound
(
$"Account with HumanID
{
humanId
}
not found."
);
}
// Return the account details
return
Ok
(
account
);
}
catch
(
Exception
ex
)
{
// Handle any potential exceptions
return
BadRequest
(
$"An error occurred while retrieving the account:
{
ex
.
Message
}
"
);
}
}
[
HttpPost
(
"accounts"
)]
public
async
Task
<
IActionResult
>
Post
(
Account
newAccount
)
{
...
...
@@ -81,7 +99,6 @@ public class RegistrationController : ControllerBase
return
CreatedAtAction
(
nameof
(
Get
),
new
{
id
=
newAccount
.
AccountID
},
newAccount
);
}
// Parameterized GET endpoint for avatars
[
HttpGet
(
"avatars/{name}"
)]
public
IActionResult
GetAvatar
(
string
name
,
[
FromQuery
]
string
format
=
"glb"
)
{
...
...
@@ -160,4 +177,22 @@ public class RegistrationController : ControllerBase
return
BadRequest
(
$"An error occurred while updating the persona for account
{
accountId
}
:
{
ex
.
Message
}
"
);
}
}
[
HttpPut
(
"accounts/{accountId}"
)]
public
async
Task
<
IActionResult
>
UpdateAccount
(
string
accountId
,
Account
updatedAccount
)
{
try
{
// Call the AccountService to update the persona in the account
await
_accountsService
.
UpdateAsync
(
accountId
,
updatedAccount
);
// Return a success response
return
Ok
(
$"Account with ID
{
updatedAccount
.
AccountID
}
was successfully updated"
);
}
catch
(
Exception
ex
)
{
// Return a bad request with the error message if something fails
return
BadRequest
(
$"An error occurred while updating the account
{
accountId
}
:
{
ex
.
Message
}
"
);
}
}
}
\ No newline at end of file
MMM-Server/MMM-Server/Models/ActionRequest.cs
0 → 100644
View file @
82275fe1
using
MongoDB.Bson.Serialization.Attributes
;
using
MongoDB.Bson
;
namespace
MMM_Server.Models
{
public
class
ActionRequest
{
[
BsonId
]
[
BsonRepresentation
(
BsonType
.
ObjectId
)]
public
string
?
ActionRequestID
{
get
;
set
;
}
public
string
Time
{
get
;
set
;
}
=
null
!;
public
string
Source
{
get
;
set
;
}
=
null
!;
public
string
Destination
{
get
;
set
;
}
=
null
!;
public
string
Action
{
get
;
set
;
}
=
null
!;
public
string
InItem
{
get
;
set
;
}
=
null
!;
public
string
InLocation
{
get
;
set
;
}
=
null
!;
public
string
OutLocation
{
get
;
set
;
}
=
null
!;
public
string
RightsID
{
get
;
set
;
}
=
null
!;
}
}
MMM-Server/MMM-Server/Models/ActionResponse.cs
0 → 100644
View file @
82275fe1
namespace
MMM_Server.Models
{
public
class
ActionResponse
{
public
string
Response
{
get
;
set
;
}
=
null
!;
}
}
MMM-Server/MMM-Server/Models/ActionTypes.cs
0 → 100644
View file @
82275fe1
namespace
MMM_Server.Models
{
public
static
class
ActionTypes
{
public
const
string
CHANGE
=
"Change"
;
public
const
string
IDENTIFY
=
"Identify"
;
public
const
string
MODIFY
=
"Modify"
;
public
const
string
TRACK
=
"Track"
;
public
const
string
MM_ANIMATE
=
"MM-Animate"
;
public
const
string
MM_DISABLE
=
"MM-Disable"
;
public
const
string
MM_EMBED
=
"MM-Embed"
;
public
const
string
MM_SEND
=
"MM-Send"
;
public
const
string
MM_VIEW
=
"MM-View"
;
public
const
string
MM_ENABLE
=
"MM-Enable"
;
public
const
string
MU_ACTUATE
=
"MU-Actuate"
;
public
const
string
MU_RENDER
=
"MU-Render"
;
public
const
string
UM_CAPTURE
=
"UM-Capture"
;
}
}
MMM-Server/MMM-Server/Models/MMMDatabaseSettings.cs
View file @
82275fe1
...
...
@@ -3,15 +3,13 @@
public
class
MMMDatabaseSettings
{
public
string
ConnectionString
{
get
;
set
;
}
=
null
!;
public
string
DatabaseName
{
get
;
set
;
}
=
null
!;
public
string
ProfilesCollectionName
{
get
;
set
;
}
=
null
!;
public
string
UsersCollectionName
{
get
;
set
;
}
=
null
!;
public
string
PersonaeCollectionName
{
get
;
set
;
}
=
null
!;
public
string
DevicesCollectionName
{
get
;
set
;
}
=
null
!;
public
string
AccountsCollectionName
{
get
;
set
;
}
=
null
!;
public
string
ActionsCollectionName
{
get
;
set
;
}
=
null
!;
}
...
...
MMM-Server/MMM-Server/Program.cs
View file @
82275fe1
...
...
@@ -10,11 +10,21 @@ builder.Services.AddSingleton<UserService>();
builder
.
Services
.
AddSingleton
<
DeviceService
>();
builder
.
Services
.
AddSingleton
<
PersonaService
>();
builder
.
Services
.
AddSingleton
<
AccountService
>();
builder
.
Services
.
AddSingleton
<
ActionService
>();
builder
.
Services
.
AddControllers
();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder
.
Services
.
AddEndpointsApiExplorer
();
builder
.
Services
.
AddSwaggerGen
();
//builder.Services.AddSwaggerGen();
builder
.
Services
.
AddSwaggerGen
(
options
=>
{
options
.
SwaggerDoc
(
"v1"
,
new
Microsoft
.
OpenApi
.
Models
.
OpenApiInfo
{
Title
=
"MMM Services Web Server"
,
Version
=
"v1"
,
Description
=
"API documentation for MMM Services Web Server"
// Optional: Add a description
});
});
var
app
=
builder
.
Build
();
...
...
MMM-Server/MMM-Server/Resources/Personae/Female2.glb
0 → 100644
View file @
82275fe1
File added
MMM-Server/MMM-Server/Resources/Personae/Female2.json
0 → 100644
View file @
82275fe1
{
"BodyType"
:
"fullbody"
,
"OutfitGender"
:
2
,
"UpdatedAt"
:
"2024-12-12T09:06:20.35Z"
,
"SkinTone"
:
"#c88d7e"
}
\ No newline at end of file
MMM-Server/MMM-Server/Resources/Personae/Female2.png
0 → 100644
View file @
82275fe1
521 KB
MMM-Server/MMM-Server/Resources/Personae/Male2.glb
0 → 100644
View file @
82275fe1
File added
MMM-Server/MMM-Server/Resources/Personae/Male2.json
0 → 100644
View file @
82275fe1
{
"BodyType"
:
"fullbody"
,
"OutfitGender"
:
1
,
"UpdatedAt"
:
"2024-12-12T09:08:14.352Z"
,
"SkinTone"
:
"#91402c"
}
\ No newline at end of file
MMM-Server/MMM-Server/Resources/Personae/Male2.png
0 → 100644
View file @
82275fe1
604 KB
MMM-Server/MMM-Server/Services/AccountService.cs
View file @
82275fe1
...
...
@@ -61,8 +61,34 @@ public class AccountService : MongoDbService<Account>
}
}
}
public
async
Task
UpdateAsync
(
string
id
,
Account
updatedItem
)
{
// Filter to find the account by its AccountID
var
filter
=
Builders
<
Account
>.
Filter
.
Eq
(
account
=>
account
.
AccountID
,
id
);
// Find the account
var
account
=
await
_collection
.
Find
(
filter
).
FirstOrDefaultAsync
();
if
(
account
==
null
)
{
throw
new
Exception
(
$"Account with ID
{
id
}
not found."
);
}
// Update the Account
var
result
=
await
_collection
.
ReplaceOneAsync
(
filter
,
updatedItem
);
// Throw exception if the update fails
if
(
result
.
MatchedCount
==
0
)
{
throw
new
Exception
(
$"Failed to update the account with ID
{
id
}
."
);
}
}
public
async
Task
<
Account
>
GetByHumanIdAsync
(
string
humanId
)
{
// Build the filter to query the database for the HumanID
var
filter
=
Builders
<
Account
>.
Filter
.
Eq
(
account
=>
account
.
HumanID
,
humanId
);
// Fetch the first matching account or return null if not found
return
await
_collection
.
Find
(
filter
).
FirstOrDefaultAsync
();
}
}
\ No newline at end of file
MMM-Server/MMM-Server/Services/ActionService.cs
0 → 100644
View file @
82275fe1
using
Microsoft.Extensions.Options
;
using
MMM_Server.Models
;
namespace
MMM_Server.Services
{
public
class
ActionService
:
MongoDbService
<
ActionRequest
>
{
public
ActionService
(
IOptions
<
MMMDatabaseSettings
>
actionDatabaseSettings
)
:
base
(
actionDatabaseSettings
,
actionDatabaseSettings
.
Value
.
ActionsCollectionName
)
{
}
}
}
MMM-Server/MMM-Server/Services/MongoDbService.cs
View file @
82275fe1
...
...
@@ -22,16 +22,6 @@ public class MongoDbService<T>
public
async
Task
CreateAsync
(
T
newItem
)
=>
await
_collection
.
InsertOneAsync
(
newItem
);
//TODO: complete following defintions
//public async Task UpdateAsync(string id, T updatedItem) =>
// await _collection.ReplaceOneAsync(x => x.Id == id, updatedItem);
//public async Task RemoveAsync(string id) =>
// await _collection.DeleteOneAsync(x => x.Id == id);
//public async Task<T?> GetAsync(string id) =>
// await _collection.Find(x => x.Id == id).FirstOrDefaultAsync();
}
MMM-Server/MMM-Server/appsettings.json
View file @
82275fe1
...
...
@@ -6,7 +6,8 @@
"UsersCollectionName"
:
"Users"
,
"DevicesCollectionName"
:
"Devices"
,
"PersonaeCollectionName"
:
"Personae"
,
"AccountsCollectionName"
:
"Accounts"
"AccountsCollectionName"
:
"Accounts"
,
"ActionsCollectionName"
:
"Actions"
},
"Logging"
:
{
...
...
MMM-Server/MMM-Server/bin/Debug/net8.0/MMM-Server.dll
View file @
82275fe1
No preview for this file type
MMM-Server/MMM-Server/bin/Debug/net8.0/MMM-Server.exe
View file @
82275fe1
No preview for this file type
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment