Skip to content

Commit d9ef89c

Browse files
committed
Add blocked and expiration info to contact sync message
1 parent 8e46d60 commit d9ef89c

File tree

6 files changed

+301
-142
lines changed

6 files changed

+301
-142
lines changed
Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
using Strilanc.Value;
2-
3-
namespace libsignalservice.messages.multidevice
1+
namespace libsignalservice.messages.multidevice
42
{
5-
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
6-
public class DeviceContact
3+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
4+
public class DeviceContact
75
{
86
public string Number { get; }
9-
public string Name { get; }
10-
public SignalServiceAttachmentStream Avatar { get; }
11-
public string Color { get; }
7+
public string Name { get; }
8+
public SignalServiceAttachmentStream Avatar { get; }
9+
public string Color { get; }
1210
public VerifiedMessage Verified { get; }
13-
public byte[] ProfileKey { get; }
14-
15-
public DeviceContact(string number, string name, SignalServiceAttachmentStream avatar, string color, VerifiedMessage verified, byte[] profileKey)
16-
{
17-
Number = number;
18-
Name = name;
19-
Avatar = avatar;
20-
Color = color;
11+
public byte[] ProfileKey { get; }
12+
public bool Blocked { get; }
13+
public int? ExpirationTimer { get; }
14+
15+
public DeviceContact(string number, string name, SignalServiceAttachmentStream avatar, string color, VerifiedMessage verified, byte[] profileKey, bool blocked, int? expirationTimer)
16+
{
17+
Number = number;
18+
Name = name;
19+
Avatar = avatar;
20+
Color = color;
2121
Verified = verified;
22-
ProfileKey = profileKey;
23-
}
22+
ProfileKey = profileKey;
23+
Blocked = blocked;
24+
ExpirationTimer = expirationTimer;
25+
}
2426
}
25-
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
26-
}
27+
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
28+
}

libsignal-service-dotnet/messages/multidevice/DeviceContactsInputStream.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
using System.IO;
2020

2121
namespace libsignalservice.messages.multidevice
22-
{
23-
public class DeviceContactsInputStream : ChunkedInputStream
22+
{
23+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
24+
public class DeviceContactsInputStream : ChunkedInputStream
2425
{
2526
public DeviceContactsInputStream(Stream input)
2627
: base(input)
@@ -50,5 +51,6 @@ public DeviceContact read()// throws IOException
5051
return new DeviceContact(number, name, avatar);*/
5152
throw new NotImplementedException();
5253
}
53-
}
54+
}
55+
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
5456
}

libsignal-service-dotnet/messages/multidevice/DeviceGroup.cs

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,47 +20,26 @@
2020
using System.Collections.Generic;
2121

2222
namespace libsignalservice.messages.multidevice
23-
{
24-
public class DeviceGroup
23+
{
24+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
25+
public class DeviceGroup
2526
{
26-
private readonly byte[] id;
27-
private readonly May<String> name;
28-
private readonly IList<String> members;
29-
private readonly May<SignalServiceAttachmentStream> avatar;
30-
private readonly bool active;
31-
32-
public DeviceGroup(byte[] id, May<String> name, IList<String> members, May<SignalServiceAttachmentStream> avatar, bool active)
33-
{
34-
this.id = id;
35-
this.name = name;
36-
this.members = members;
37-
this.avatar = avatar;
38-
this.active = active;
39-
}
40-
41-
public May<SignalServiceAttachmentStream> getAvatar()
42-
{
43-
return avatar;
44-
}
45-
46-
public May<String> getName()
47-
{
48-
return name;
49-
}
50-
51-
public byte[] getId()
52-
{
53-
return id;
54-
}
55-
56-
public IList<String> getMembers()
57-
{
58-
return members;
59-
}
60-
61-
public bool isActive()
27+
public byte[] Id { get; }
28+
public String Name { get; }
29+
public IList<String> Members { get; }
30+
public SignalServiceAttachmentStream Avatar { get; }
31+
public bool Active { get; }
32+
public int? ExpirationTimer { get; }
33+
34+
public DeviceGroup(byte[] id, string name, IList<string> members, SignalServiceAttachmentStream avatar, bool active, int? expirationTimer)
6235
{
63-
return active;
36+
Id = id;
37+
Name = name;
38+
Members = members;
39+
Avatar = avatar;
40+
Active = active;
41+
ExpirationTimer = expirationTimer;
6442
}
65-
}
43+
}
44+
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
6645
}
Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,66 @@
1-
using Google.Protobuf;
2-
using libsignalservice.push;
3-
4-
using System;
5-
using System.IO;
6-
7-
namespace libsignalservice.messages.multidevice
8-
{
9-
internal class DeviceGroupsOutputStream : ChunkedOutputStream
10-
{
11-
public DeviceGroupsOutputStream(Stream output)
12-
: base(output)
13-
{
14-
}
15-
16-
public void write(DeviceGroup group)
17-
{
18-
writeGroupDetails(group);
19-
writeAvatarImage(group);
20-
}
21-
22-
public void close()
23-
{
24-
//output.close();
25-
}
26-
27-
private void writeAvatarImage(DeviceGroup contact)
28-
{
29-
if (contact.getAvatar().HasValue)
1+
using Google.Protobuf;
2+
using libsignalservice.push;
3+
4+
using System;
5+
using System.IO;
6+
7+
namespace libsignalservice.messages.multidevice
8+
{
9+
internal class DeviceGroupsOutputStream : ChunkedOutputStream
10+
{
11+
public DeviceGroupsOutputStream(Stream output)
12+
: base(output)
13+
{
14+
}
15+
16+
public void write(DeviceGroup group)
17+
{
18+
WriteGroupDetails(group);
19+
writeAvatarImage(group);
20+
}
21+
22+
public void close()
23+
{
24+
//output.close();
25+
}
26+
27+
private void writeAvatarImage(DeviceGroup contact)
28+
{
29+
if (contact.Avatar != null)
3030
{
31-
throw new NotImplementedException();
32-
//contact.getAvatar().Match(e => e, () => { throw new Exception(); }).InputStream;
33-
}
34-
}
35-
36-
private void writeGroupDetails(DeviceGroup group)// throws IOException
37-
{
38-
GroupDetails groupDetails = new GroupDetails { };
39-
groupDetails.Id = ByteString.CopyFrom(group.getId());
40-
41-
if (group.getName().HasValue)
42-
{
43-
groupDetails.Name = group.getName().Match(e => e, () => { throw new Exception(); });
44-
}
45-
46-
if (group.getAvatar().HasValue)
47-
{
48-
GroupDetails.Types.Avatar avatarBuilder = new GroupDetails.Types.Avatar { };
49-
SignalServiceAttachmentStream avatar = group.getAvatar().Match(e => e, () => { throw new Exception(); });
50-
avatarBuilder.ContentType = avatar.getContentType();
51-
avatarBuilder.Length = (uint)avatar.Length;
52-
groupDetails.Avatar = avatarBuilder;
53-
}
54-
55-
groupDetails.Members.AddRange(group.getMembers());
56-
groupDetails.Active = group.isActive();
57-
58-
byte[] serializedContactDetails = groupDetails.ToByteArray();
59-
60-
writeVarint32(serializedContactDetails.Length);
61-
output.Write(serializedContactDetails, 0, serializedContactDetails.Length);
62-
}
63-
}
64-
}
31+
throw new NotImplementedException();
32+
//contact.getAvatar().Match(e => e, () => { throw new Exception(); }).InputStream;
33+
}
34+
}
35+
36+
private void WriteGroupDetails(DeviceGroup group)// throws IOException
37+
{
38+
GroupDetails groupDetails = new GroupDetails { };
39+
groupDetails.Id = ByteString.CopyFrom(group.Id);
40+
41+
if (group.Name != null)
42+
{
43+
//groupDetails.Name = group.getName().Match(e => e, () => { throw new Exception(); });
44+
}
45+
46+
if (group.Avatar != null)
47+
{
48+
GroupDetails.Types.Avatar avatarBuilder = new GroupDetails.Types.Avatar { };
49+
//SignalServiceAttachmentStream avatar = group.getAvatar().Match(e => e, () => { throw new Exception(); });
50+
//avatarBuilder.ContentType = avatar.C;
51+
//avatarBuilder.Length = (uint)avatar.Length;
52+
groupDetails.Avatar = avatarBuilder;
53+
}
54+
55+
//if (group.ExpirationTimer
56+
57+
groupDetails.Members.AddRange(group.Members);
58+
groupDetails.Active = group.Active;
59+
60+
byte[] serializedContactDetails = groupDetails.ToByteArray();
61+
62+
writeVarint32(serializedContactDetails.Length);
63+
output.Write(serializedContactDetails, 0, serializedContactDetails.Length);
64+
}
65+
}
66+
}

libsignal-service-dotnet/protobuf/SignalService.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ message ContactDetails {
206206
oneof color_oneof { string color = 4; }
207207
oneof verified_oneof { Verified verified = 5; }
208208
oneof profileKey_oneof { bytes profileKey = 6; }
209+
oneof blocked_oneof { bool blocked = 7; }
210+
oneof expireTimer_oneof { uint32 expireTimer = 8; }
209211
}
210212

211213
message GroupDetails {
@@ -219,4 +221,5 @@ message GroupDetails {
219221
repeated string members = 3;
220222
oneof avatar_oneof { Avatar avatar = 4; }
221223
oneof active_oneof { bool active = 5; } //[default = true] ### }
224+
oneof expireTimer_oneof { uint32 expireTimer = 6; }
222225
}

0 commit comments

Comments
 (0)