Skip to content

Commit d2a8438

Browse files
committed
Changed the file structure around a bit.
1 parent 21c3470 commit d2a8438

File tree

6 files changed

+114
-135
lines changed

6 files changed

+114
-135
lines changed
File renamed without changes.

Models/index.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './user.mjs';
File renamed without changes.

Models/user.js

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 112 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,113 @@
1-
/**
2-
* Combadge-protocol, an implementation of an OEM Combadge control protocol for Spin Doctor
3-
* Copyright (C) 2021-2022 The Combadge Project by mo-g
4-
*
5-
* Combadge-protocol is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU Affero General Public License as published by
7-
* the Free Software Foundation, version 3 of the License.
8-
*
9-
* Combadge-protocol is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
* GNU General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with Combadge-protocol. If not, see <https://www.gnu.org/licenses/>.
16-
*/
17-
18-
userTemplate = {
19-
userName: "u-fallbackuser", // Globally unique ID
20-
fullName: new UserFullName(foreName = "Fallback", familyName = "User", nickName = "Fallback User"),
21-
ipaPronunciation: "fɔːlbæk ˈjuːzə", // Not currently in use for STT or TTS but worth adding.
22-
associatedGroups: [],
23-
24-
assignedBadge: "ba:dg:em:ac:ad:dr", // Optional, for autologin/whitelisting
25-
personalTerminals: [] // Being vidcom terminals that can be used to make video calls.
26-
};
27-
28-
groupTemplate = {
29-
groupName: "g-allhands",
30-
nickName: "All Hands",
31-
ipaPronunciation: "ɔːl hændz", // Not currently in use for STT or TTS but worth adding.
32-
associatedUsers: [],
33-
34-
assignedAddress: "Placeholder for multicast IPAddress Object"
35-
};
36-
37-
38-
/**
39-
* Frst pass. Probably want to restructure this to allow returning different form of name.
40-
*
41-
* Assume middle names to include patronyms. Should obviously be treated as an ordered list regardless.
42-
* Do we want to merge pronunciation in to this as well?
43-
*/
44-
class UserFullName {
45-
constructor ({prefix = "", foreName = "", middleNames = [], familyName = "", suffix = "", nickName = ""} = {}) {
46-
this.prefix = prefix;
47-
this.foreName = foreName;
48-
this.middleNames = middleNames;
49-
this.familyName = familyName;
50-
this.suffix = suffix;
51-
this.nickName = nickName;
52-
53-
preferredFormat = this.fullName;
54-
};
55-
56-
fullName () {
57-
var assembled = "";
58-
if (this.prefix) {assembled += this.prefix};
59-
if (this.foreName) {assembled += this.foreName};
60-
if (this.middleNames) {
61-
this.middleNames.forEach(function (name) {
62-
assembled += name;
63-
});
64-
};
65-
if (this.familyName) {assembled += this.familyName};
66-
if (this.suffix) {assembled += this.suffix};
67-
68-
if (assembled) {
69-
return assembled;
70-
} else {
71-
throw "Cannot stringify empty name."
72-
};
73-
};
74-
75-
toString () {
76-
return this.preferredFormat();
77-
};
78-
79-
}
80-
81-
class User {
82-
constructor () {
83-
84-
};
85-
};
86-
87-
class Group {
88-
constructor () {
89-
90-
};
91-
};
92-
1+
/**
2+
* Spin Doctor, a Combadge Voice Server
3+
* Copyright (C) 2021-2022 The Combadge Project by mo-g
4+
*
5+
* Spin Doctor is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, version 3 of the License.
8+
*
9+
* Spin Doctor is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with Spin Doctor. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
19+
/**
20+
* User class describes a person who signs in to a Communicator. A User will
21+
* have the following mandatory attributes:
22+
* - username: a unique identifier. This will link a User object to it's source
23+
* in the database, and will be derived from and associated to any directory.
24+
* - name: The user's human-readable name as they or the directory records.
25+
*
26+
* Additionally, a User may have the following optional attributes:
27+
* - presence: A representation of the presence state of the user. This could
28+
* be offline, available, DND, in-call.
29+
* - permittedContacts: A machine readable reference to the contacts permitted
30+
* to contact this user. i.e. in SME, allow your secretary to contact the CEO
31+
* but not the chaiwala. Should probably handle state-dependent logic - i.e.
32+
* allow your partner to contact you in DND mode, but not your mother-in-law.
33+
* - personalContacts: A store of the contacts that relate specifically to you.
34+
* E.G. Your pharmacy, your work. This allows shorthands that wouldn't make
35+
* sense when used by other people.
36+
*/
37+
38+
userTemplate = {
39+
userName: "u-fallbackuser", // Globally unique ID
40+
fullName: new UserFullName(foreName = "Fallback", familyName = "User", nickName = "Fallback User"),
41+
ipaPronunciation: "fɔːlbæk ˈjuːzə", // Not currently in use for STT or TTS but worth adding.
42+
associatedGroups: [],
43+
44+
assignedDevices: ["ba:dg:em:ac:ad:dr"], // Optional, for autologin/whitelisting
45+
personalTerminals: ["te:rm:in:al:ma:cs"] // Being vidcom terminals that can be used to make video calls.
46+
};
47+
48+
groupTemplate = {
49+
groupName: "g-allhands",
50+
nickName: "All Hands",
51+
ipaPronunciation: "ɔːl hændz", // Not currently in use for STT or TTS but worth adding.
52+
associatedUsers: [],
53+
54+
assignedAddress: "Placeholder for multicast IPAddress Object"
55+
};
56+
57+
58+
/**
59+
* Frst pass. Probably want to restructure this to allow returning different form of name.
60+
*
61+
* Assume middle names to include patronyms. Should obviously be treated as an ordered list regardless.
62+
* Do we want to merge pronunciation in to this as well?
63+
*/
64+
class UserFullName {
65+
constructor ({prefix = "", foreName = "", middleNames = [], familyName = "", suffix = "", nickName = ""} = {}) {
66+
this.prefix = prefix;
67+
this.foreName = foreName;
68+
this.middleNames = middleNames;
69+
this.familyName = familyName;
70+
this.suffix = suffix;
71+
this.nickName = nickName;
72+
73+
preferredFormat = this.fullName;
74+
};
75+
76+
fullName () {
77+
var assembled = "";
78+
if (this.prefix) {assembled += this.prefix};
79+
if (this.foreName) {assembled += this.foreName};
80+
if (this.middleNames) {
81+
this.middleNames.forEach(function (name) {
82+
assembled += name;
83+
});
84+
};
85+
if (this.familyName) {assembled += this.familyName};
86+
if (this.suffix) {assembled += this.suffix};
87+
88+
if (assembled) {
89+
return assembled;
90+
} else {
91+
throw "Cannot stringify empty name."
92+
};
93+
};
94+
95+
toString () {
96+
return this.preferredFormat();
97+
};
98+
99+
}
100+
101+
class User {
102+
constructor () {
103+
104+
};
105+
};
106+
107+
class Group {
108+
constructor () {
109+
110+
};
111+
};
112+
93113
export { User, Group };

combadged.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import dgram from 'dgram';
2727
import { CombadgePacket, Combadge } from './Libraries/ecma-cccp/index.mjs';
28+
import { User, Group } from './Models/index.mjs';
2829
import { Agent } from './Libraries/robin-agent/index.mjs';
2930
import { RTPHeader, RTPPacket } from './Libraries/ecma-rtp/index.mjs';
3031
import express from 'express';

0 commit comments

Comments
 (0)