Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
xx messenger iOS
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
xx messenger iOS
Commits
98b79822
Commit
98b79822
authored
2 years ago
by
Bruno Muniz
Browse files
Options
Downloads
Patches
Plain Diff
Trying to fix group issue
parent
c4a6b634
No related branches found
Branches containing commit
No related tags found
2 merge requests
!40
v1.1.2b166
,
!38
Using new database structure
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/Integration/Session/Session+Chat.swift
+6
-2
6 additions, 2 deletions
Sources/Integration/Session/Session+Chat.swift
Sources/Integration/Session/Session+Group.swift
+72
-15
72 additions, 15 deletions
Sources/Integration/Session/Session+Group.swift
with
78 additions
and
17 deletions
Sources/Integration/Session/Session+Chat.swift
+
6
−
2
View file @
98b79822
...
...
@@ -124,12 +124,16 @@ extension Session {
message
.
date
=
Date
()
if
let
message
=
try
?
dbManager
.
saveMessage
(
message
)
{
send
(
message
:
message
)
if
let
recipientId
=
message
.
recipientId
{
send
(
message
:
message
)
}
else
{
send
(
groupMessage
:
message
)
}
}
}
}
private
func
send
(
message
:
Message
)
{
func
send
(
message
:
Message
)
{
var
message
=
message
var
reply
:
Reply
?
...
...
This diff is collapsed.
Click to expand it.
Sources/Integration/Session/Session+Group.swift
+
72
−
15
View file @
98b79822
...
...
@@ -25,17 +25,49 @@ extension Session {
members
:
[
Contact
],
_
completion
:
@escaping
(
Result
<
GroupInfo
,
Error
>
)
->
Void
)
{
guard
let
manager
=
client
.
groupManager
else
{
fatalError
(
"A group manager was not created"
)
}
let
me
=
client
.
bindings
.
meMarshalled
let
memberIds
=
members
.
map
{
$0
.
id
}
guard
let
manager
=
client
.
groupManager
else
{
fatalError
(
"A group manager was not created"
)
}
manager
.
create
(
me
:
me
,
name
:
name
,
welcome
:
welcome
,
with
:
memberIds
)
{
[
weak
self
]
in
manager
.
create
(
me
:
myId
,
name
:
name
,
welcome
:
welcome
,
with
:
members
.
map
{
$0
.
id
})
{
[
weak
self
]
result
in
guard
let
self
=
self
else
{
return
}
switch
$0
{
switch
result
{
case
.
success
(
let
group
):
completion
(
.
success
(
self
.
processGroupCreation
(
group
,
memberIds
:
memberIds
,
welcome
:
welcome
)))
try!
self
.
dbManager
.
saveGroup
(
group
)
members
.
map
{
GroupMember
(
groupId
:
group
.
id
,
contactId
:
$0
.
id
)
}
.
forEach
{
try!
self
.
dbManager
.
saveGroupMember
(
$0
)
}
// TODO: Add saveBulkGroupMembers to the database
if
let
welcome
=
welcome
{
let
message
=
Message
(
networkId
:
nil
,
senderId
:
self
.
myId
,
recipientId
:
nil
,
groupId
:
group
.
id
,
date
:
group
.
createdAt
,
status
:
.
received
,
isUnread
:
false
,
text
:
welcome
,
replyMessageId
:
nil
,
roundURL
:
nil
,
fileTransferId
:
nil
)
try!
self
.
dbManager
.
saveMessage
(
message
)
}
let
query
=
GroupInfo
.
Query
(
groupId
:
group
.
id
)
let
info
=
try!
self
.
dbManager
.
fetchGroupInfos
(
query
)
.
first
completion
(
.
success
(
info
!
))
case
.
failure
(
let
error
):
completion
(
.
failure
(
error
))
}
...
...
@@ -48,9 +80,35 @@ extension Session {
///
_
=
try!
dbManager
.
saveGroup
(
group
)
///
Save
the members
///
Which of
th
os
e members
are not my friends?
///
memberIds
.
forEach
{
_
=
try!
dbManager
.
saveGroupMember
(
.
init
(
groupId
:
group
.
id
,
contactId
:
$0
))
}
let
friendsParticipating
=
try!
dbManager
.
fetchContacts
(
Contact
.
Query
(
id
:
Set
(
memberIds
)))
/// Save the strangers as contacts
///
let
friendIds
=
friendsParticipating
.
map
(\
.
id
)
memberIds
.
forEach
{
if
!
friendIds
.
contains
(
$0
)
{
try!
dbManager
.
saveContact
(
.
init
(
id
:
$0
,
marshaled
:
nil
,
username
:
nil
,
email
:
nil
,
phone
:
nil
,
nickname
:
nil
,
photo
:
nil
,
authStatus
:
.
stranger
,
isRecent
:
false
,
createdAt
:
Date
()
))
}
}
/// Save group members relation
///
memberIds
.
forEach
{
try!
dbManager
.
saveGroupMember
(
.
init
(
groupId
:
group
.
id
,
contactId
:
$0
))
}
/// Save the welcome message (if any)
///
...
...
@@ -70,9 +128,8 @@ extension Session {
))
}
/// Buzz if the group was not created by me
///
if
group
.
leaderId
!=
client
.
bindings
.
myId
,
inappnotifications
{
if
inappnotifications
{
DeviceFeedback
.
sound
(
.
contactAdded
)
DeviceFeedback
.
shake
(
.
notification
)
}
...
...
@@ -103,15 +160,15 @@ extension Session {
do
{
message
=
try
dbManager
.
saveMessage
(
message
)
send
(
m
essage
:
message
)
send
(
groupM
essage
:
message
)
}
catch
{
log
(
string
:
error
.
localizedDescription
,
type
:
.
error
)
}
}
private
func
send
(
m
essage
:
Message
)
{
func
send
(
groupM
essage
:
Message
)
{
guard
let
manager
=
client
.
groupManager
else
{
fatalError
(
"A group manager was not created"
)
}
var
message
=
m
essage
var
message
=
groupM
essage
var
reply
:
Reply
?
if
let
replyId
=
message
.
replyMessageId
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment