Skip to content

Commit

Permalink
Remove unnecessary uploading logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Oct 13, 2023
1 parent fac253b commit 0b9300e
Showing 1 changed file with 0 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,53 +149,6 @@ private async Task ResolveChainUid(MessageChain chain)
}
break;
}
case ImageEntity image:
{
if (!chain.IsGroup)
{
string uid = await Collection.Business.CachingLogic.ResolveUid(chain.GroupUin, chain.FriendUin) ?? throw new Exception($"Failed to resolve Uid for Uin {chain.FriendUin}");
var @event = ImageUploadEvent.Create(image.ImageStream, uid);
var results = await Collection.Business.SendEvent(@event);
if (results.Count != 0)
{
var ticketResult = (ImageUploadEvent)results[0];
if (!ticketResult.IsExist)
{
bool hwSuccess = await Collection.Highway.UploadSrcByStreamAsync(1, Collection.Keystore.Uin, image.ImageStream, ticketResult.Ticket, @event.FileMd5.UnHex());
if (!hwSuccess)
{
Collection.Log.LogFatal(Tag, "Failed to upload image to highway");
continue;
}
}

image.ImageStream = @event.Stream;
image.Path = ticketResult.ServerPath;
}
}
else
{
var @event = ImageGroupUploadEvent.Create(image.ImageStream, chain.GroupUin ?? throw new Exception());
var results = await Collection.Business.SendEvent(@event);
if (results.Count != 0)
{
var ticketResult = (ImageGroupUploadEvent)results[0];
if (!ticketResult.IsExist)
{
bool hwSuccess = await Collection.Highway.UploadSrcByStreamAsync(2, Collection.Keystore.Uin, image.ImageStream, ticketResult.Ticket, @event.FileMd5.UnHex());
if (!hwSuccess)
{
Collection.Log.LogFatal(Tag, "Failed to upload image to highway");
continue;
}
}

image.ImageStream = @event.Stream;
image.FileId = ticketResult.FileId;
}
}
break;
}
}
}
}
Expand Down

0 comments on commit 0b9300e

Please sign in to comment.