Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
eb72069c
Commit
eb72069c
authored
Aug 11, 2024
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add id to chat messages.
parent
4fb0b333
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
22 deletions
+34
-22
group/group.go
group/group.go
+8
-7
group/group_test.go
group/group_test.go
+1
-1
rtpconn/webclient.go
rtpconn/webclient.go
+18
-9
static/galene.js
static/galene.js
+5
-3
static/protocol.js
static/protocol.js
+2
-2
No files found.
group/group.go
View file @
eb72069c
...
...
@@ -75,6 +75,7 @@ func (err ProtocolError) Error() string {
type
ChatHistoryEntry
struct
{
Id
string
Source
string
User
*
string
Time
time
.
Time
Kind
string
...
...
@@ -804,7 +805,7 @@ func (g *Group) ClearChatHistory() {
g
.
history
=
nil
}
func
(
g
*
Group
)
AddToChatHistory
(
id
string
,
user
*
string
,
time
time
.
Time
,
kind
string
,
value
interface
{})
{
func
(
g
*
Group
)
AddToChatHistory
(
id
,
source
string
,
user
*
string
,
time
time
.
Time
,
kind
string
,
value
interface
{})
{
g
.
mu
.
Lock
()
defer
g
.
mu
.
Unlock
()
...
...
@@ -813,7 +814,7 @@ func (g *Group) AddToChatHistory(id string, user *string, time time.Time, kind s
g
.
history
=
g
.
history
[
:
len
(
g
.
history
)
-
1
]
}
g
.
history
=
append
(
g
.
history
,
ChatHistoryEntry
{
Id
:
id
,
User
:
user
,
Time
:
time
,
Kind
:
kind
,
Value
:
value
},
ChatHistoryEntry
{
Id
:
id
,
Source
:
source
,
User
:
user
,
Time
:
time
,
Kind
:
kind
,
Value
:
value
},
)
}
...
...
group/group_test.go
View file @
eb72069c
...
...
@@ -54,7 +54,7 @@ func TestChatHistory(t *testing.T) {
}
user
:=
"user"
for
i
:=
0
;
i
<
2
*
maxChatHistory
;
i
++
{
g
.
AddToChatHistory
(
"id"
,
&
user
,
time
.
Now
(),
""
,
g
.
AddToChatHistory
(
"id"
,
"source"
,
&
user
,
time
.
Now
(),
""
,
fmt
.
Sprintf
(
"%v"
,
i
),
)
}
...
...
rtpconn/webclient.go
View file @
eb72069c
...
...
@@ -1197,7 +1197,8 @@ func handleAction(c *webClient, a any) error {
for
_
,
m
:=
range
h
{
err
:=
c
.
write
(
clientMessage
{
Type
:
"chathistory"
,
Source
:
m
.
Id
,
Id
:
m
.
Id
,
Source
:
m
.
Source
,
Username
:
m
.
User
,
Time
:
m
.
Time
.
Format
(
time
.
RFC3339
),
Value
:
m
.
Value
,
...
...
@@ -1575,17 +1576,25 @@ func handleClientMessage(c *webClient, m clientMessage) error {
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
}
now
:=
time
.
Now
()
id
:=
m
.
Id
if
m
.
Type
==
"chat"
&&
m
.
Dest
==
""
&&
id
==
""
{
buf
:=
make
([]
byte
,
8
)
crand
.
Read
(
buf
)
id
=
base64
.
RawURLEncoding
.
EncodeToString
(
buf
)
}
now
:=
time
.
Now
()
if
m
.
Type
==
"chat"
{
if
m
.
Dest
==
""
{
g
.
AddToChatHistory
(
m
.
Source
,
m
.
Username
,
now
,
m
.
Kind
,
m
.
Value
,
id
,
m
.
Source
,
m
.
Username
,
now
,
m
.
Kind
,
m
.
Value
,
)
}
}
mm
:=
clientMessage
{
Type
:
m
.
Type
,
Id
:
id
,
Source
:
m
.
Source
,
Dest
:
m
.
Dest
,
Username
:
m
.
Username
,
...
...
@@ -1891,9 +1900,9 @@ func handleClientMessage(c *webClient, m clientMessage) error {
}
w
,
ok
:=
d
.
(
warner
)
if
ok
{
w
.
Warn
(
false
,
"Your IP address has been "
+
"communicated to user "
+
c
.
Username
()
+
"."
)
w
.
Warn
(
false
,
"Your IP address has been "
+
"communicated to user "
+
c
.
Username
()
+
"."
)
}
c
.
write
(
clientMessage
{
Type
:
"usermessage"
,
...
...
static/galene.js
View file @
eb72069c
...
...
@@ -2958,7 +2958,7 @@ let lastMessage = {};
* @param {string} kind
* @param {string|HTMLElement} message
*/
function
addToChatbox
(
peerId
,
dest
,
nick
,
time
,
privileged
,
history
,
kind
,
message
)
{
function
addToChatbox
(
id
,
peerId
,
dest
,
nick
,
time
,
privileged
,
history
,
kind
,
message
)
{
let
row
=
document
.
createElement
(
'
div
'
);
row
.
classList
.
add
(
'
message-row
'
);
let
container
=
document
.
createElement
(
'
div
'
);
...
...
@@ -2973,6 +2973,8 @@ function addToChatbox(peerId, dest, nick, time, privileged, history, kind, messa
if
(
dest
)
container
.
classList
.
add
(
'
message-private
'
);
if
(
id
)
container
.
dataset
.
id
=
id
;
if
(
peerId
)
{
container
.
dataset
.
peerId
=
peerId
;
container
.
dataset
.
username
=
nick
;
...
...
@@ -3093,7 +3095,7 @@ function chatMessageMenu(elt) {
* @param {string|HTMLElement} message
*/
function
localMessage
(
message
)
{
return
addToChatbox
(
null
,
null
,
null
,
new
Date
(),
false
,
false
,
''
,
message
);
return
addToChatbox
(
null
,
null
,
null
,
n
ull
,
n
ew
Date
(),
false
,
false
,
''
,
message
);
}
function
clearChat
()
{
...
...
@@ -3473,7 +3475,7 @@ commands.msg = {
if
(
!
id
)
throw
new
Error
(
`Unknown user
${
p
[
0
]}
`
);
serverConnection
.
chat
(
''
,
id
,
p
[
1
]);
addToChatbox
(
serverConnection
.
id
,
id
,
serverConnection
.
username
,
addToChatbox
(
serverConnection
.
id
,
null
,
id
,
serverConnection
.
username
,
new
Date
(),
false
,
false
,
''
,
p
[
1
]);
}
};
...
...
static/protocol.js
View file @
eb72069c
...
...
@@ -212,7 +212,7 @@ function ServerConnection() {
/**
* onchat is called whenever a new chat message is received.
*
* @type {(this: ServerConnection, id: string, dest: string, username: string, time: Date, privileged: boolean, history: boolean, kind: string, message: string) => void}
* @type {(this: ServerConnection, id: string,
source: string,
dest: string, username: string, time: Date, privileged: boolean, history: boolean, kind: string, message: string) => void}
*/
this
.
onchat
=
null
;
/**
...
...
@@ -497,7 +497,7 @@ ServerConnection.prototype.connect = function(url) {
case
'
chathistory
'
:
if
(
sc
.
onchat
)
sc
.
onchat
.
call
(
sc
,
m
.
source
,
m
.
dest
,
m
.
username
,
parseTime
(
m
.
time
),
sc
,
m
.
id
,
m
.
source
,
m
.
dest
,
m
.
username
,
parseTime
(
m
.
time
),
m
.
privileged
,
m
.
type
===
'
chathistory
'
,
m
.
kind
,
''
+
m
.
value
,
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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