Remove this. everywhere, add small note to override style
This commit is contained in:
+46
-46
@@ -12,15 +12,15 @@ internal class SortCode {
|
||||
internal ChatSource Source { get; set; }
|
||||
|
||||
internal SortCode(ChatType type, ChatSource source) {
|
||||
this.Type = type;
|
||||
this.Source = source;
|
||||
Type = type;
|
||||
Source = source;
|
||||
}
|
||||
|
||||
public SortCode() {
|
||||
}
|
||||
|
||||
private bool Equals(SortCode other) {
|
||||
return this.Type == other.Type && this.Source == other.Source;
|
||||
return Type == other.Type && Source == other.Source;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj) {
|
||||
@@ -32,12 +32,12 @@ internal class SortCode {
|
||||
return true;
|
||||
}
|
||||
|
||||
return obj.GetType() == this.GetType() && this.Equals((SortCode) obj);
|
||||
return obj.GetType() == GetType() && Equals((SortCode) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
unchecked {
|
||||
return ((int) this.Type * 397) ^ (int) this.Source;
|
||||
return ((int) Type * 397) ^ (int) Source;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,16 +68,16 @@ internal class Message {
|
||||
internal int Hash { get; }
|
||||
|
||||
internal Message(ulong receiver, ChatCode code, List<Chunk> sender, List<Chunk> content, SeString senderSource, SeString contentSource) {
|
||||
this.Receiver = receiver;
|
||||
this.Date = DateTime.UtcNow;
|
||||
this.Code = code;
|
||||
this.Sender = sender;
|
||||
this.Content = ReplaceContentURLs(content);
|
||||
this.SenderSource = senderSource;
|
||||
this.ContentSource = contentSource;
|
||||
this.SortCode = new SortCode(this.Code.Type, this.Code.Source);
|
||||
this.ExtraChatChannel = this.ExtractExtraChatChannel();
|
||||
this.Hash = this.GenerateHash();
|
||||
Receiver = receiver;
|
||||
Date = DateTime.UtcNow;
|
||||
Code = code;
|
||||
Sender = sender;
|
||||
Content = ReplaceContentURLs(content);
|
||||
SenderSource = senderSource;
|
||||
ContentSource = contentSource;
|
||||
SortCode = new SortCode(Code.Type, Code.Source);
|
||||
ExtraChatChannel = ExtractExtraChatChannel();
|
||||
Hash = GenerateHash();
|
||||
|
||||
foreach (var chunk in sender.Concat(content)) {
|
||||
chunk.Message = this;
|
||||
@@ -85,56 +85,56 @@ internal class Message {
|
||||
}
|
||||
|
||||
internal Message(ObjectId id, ulong receiver, ulong contentId, DateTime date, BsonDocument code, BsonArray sender, BsonArray content, BsonValue senderSource, BsonValue contentSource, BsonDocument sortCode) {
|
||||
this.Id = id;
|
||||
this.Receiver = receiver;
|
||||
this.ContentId = contentId;
|
||||
this.Date = date;
|
||||
this.Code = BsonMapper.Global.ToObject<ChatCode>(code);
|
||||
this.Sender = BsonMapper.Global.Deserialize<List<Chunk>>(sender);
|
||||
Id = id;
|
||||
Receiver = receiver;
|
||||
ContentId = contentId;
|
||||
Date = date;
|
||||
Code = BsonMapper.Global.ToObject<ChatCode>(code);
|
||||
Sender = BsonMapper.Global.Deserialize<List<Chunk>>(sender);
|
||||
// Don't call ReplaceContentURLs here since we're loading the message
|
||||
// from the database and it should already have parsed URL data.
|
||||
this.Content = BsonMapper.Global.Deserialize<List<Chunk>>(content);
|
||||
this.SenderSource = BsonMapper.Global.Deserialize<SeString>(senderSource);
|
||||
this.ContentSource = BsonMapper.Global.Deserialize<SeString>(contentSource);
|
||||
this.SortCode = BsonMapper.Global.ToObject<SortCode>(sortCode);
|
||||
this.ExtraChatChannel = this.ExtractExtraChatChannel();
|
||||
this.Hash = this.GenerateHash();
|
||||
Content = BsonMapper.Global.Deserialize<List<Chunk>>(content);
|
||||
SenderSource = BsonMapper.Global.Deserialize<SeString>(senderSource);
|
||||
ContentSource = BsonMapper.Global.Deserialize<SeString>(contentSource);
|
||||
SortCode = BsonMapper.Global.ToObject<SortCode>(sortCode);
|
||||
ExtraChatChannel = ExtractExtraChatChannel();
|
||||
Hash = GenerateHash();
|
||||
|
||||
foreach (var chunk in this.Sender.Concat(this.Content)) {
|
||||
foreach (var chunk in Sender.Concat(Content)) {
|
||||
chunk.Message = this;
|
||||
}
|
||||
}
|
||||
|
||||
internal Message(ObjectId id, ulong receiver, ulong contentId, DateTime date, BsonDocument code, BsonArray sender, BsonArray content, BsonValue senderSource, BsonValue contentSource, BsonDocument sortCode, BsonValue extraChatChannel) {
|
||||
this.Id = id;
|
||||
this.Receiver = receiver;
|
||||
this.ContentId = contentId;
|
||||
this.Date = date;
|
||||
this.Code = BsonMapper.Global.ToObject<ChatCode>(code);
|
||||
this.Sender = BsonMapper.Global.Deserialize<List<Chunk>>(sender);
|
||||
Id = id;
|
||||
Receiver = receiver;
|
||||
ContentId = contentId;
|
||||
Date = date;
|
||||
Code = BsonMapper.Global.ToObject<ChatCode>(code);
|
||||
Sender = BsonMapper.Global.Deserialize<List<Chunk>>(sender);
|
||||
// Don't call ReplaceContentURLs here since we're loading the message
|
||||
// from the database and it should already have parsed URL data.
|
||||
this.Content = BsonMapper.Global.Deserialize<List<Chunk>>(content);
|
||||
this.SenderSource = BsonMapper.Global.Deserialize<SeString>(senderSource);
|
||||
this.ContentSource = BsonMapper.Global.Deserialize<SeString>(contentSource);
|
||||
this.SortCode = BsonMapper.Global.ToObject<SortCode>(sortCode);
|
||||
this.ExtraChatChannel = BsonMapper.Global.Deserialize<Guid>(extraChatChannel);
|
||||
this.Hash = this.GenerateHash();
|
||||
Content = BsonMapper.Global.Deserialize<List<Chunk>>(content);
|
||||
SenderSource = BsonMapper.Global.Deserialize<SeString>(senderSource);
|
||||
ContentSource = BsonMapper.Global.Deserialize<SeString>(contentSource);
|
||||
SortCode = BsonMapper.Global.ToObject<SortCode>(sortCode);
|
||||
ExtraChatChannel = BsonMapper.Global.Deserialize<Guid>(extraChatChannel);
|
||||
Hash = GenerateHash();
|
||||
|
||||
foreach (var chunk in this.Sender.Concat(this.Content)) {
|
||||
foreach (var chunk in Sender.Concat(Content)) {
|
||||
chunk.Message = this;
|
||||
}
|
||||
}
|
||||
|
||||
private int GenerateHash() {
|
||||
return this.SortCode.GetHashCode()
|
||||
^ this.ExtraChatChannel.GetHashCode()
|
||||
^ string.Join("", this.Sender.Select(c => c.StringValue())).GetHashCode()
|
||||
^ string.Join("", this.Content.Select(c => c.StringValue())).GetHashCode();
|
||||
return SortCode.GetHashCode()
|
||||
^ ExtraChatChannel.GetHashCode()
|
||||
^ string.Join("", Sender.Select(c => c.StringValue())).GetHashCode()
|
||||
^ string.Join("", Content.Select(c => c.StringValue())).GetHashCode();
|
||||
}
|
||||
|
||||
private Guid ExtractExtraChatChannel() {
|
||||
if (this.ContentSource.Payloads.Count > 0 && this.ContentSource.Payloads[0] is RawPayload raw) {
|
||||
if (ContentSource.Payloads.Count > 0 && ContentSource.Payloads[0] is RawPayload raw) {
|
||||
// this does an encode and clone every time it's accessed, so cache
|
||||
var data = raw.Data;
|
||||
if (data[1] == 0x27 && data[2] == 18 && data[3] == 0x20) {
|
||||
|
||||
Reference in New Issue
Block a user