Skip to content

Commit

Permalink
The absolute stupidest attempt at a fix, hope it works
Browse files Browse the repository at this point in the history
  • Loading branch information
TorutheRedFox committed Aug 8, 2024
1 parent 5b94662 commit 1303844
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions Discord Classic/DCChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ -(void)checkIfRead{

- (void)sendMessage:(NSString*)message {
dispatch_async([self get_channel_send_queue], ^{
NSURL* channelURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discord.com/api/v9/channels/%@/messages", self.snowflake]];
NSURL* channelURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discordapp.com/api/v9/channels/%@/messages", self.snowflake]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10];
[urlRequest setValue:@"no-store" forHTTPHeaderField:@"Cache-Control"];
Expand Down Expand Up @@ -92,7 +92,7 @@ - (void)sendImage:(UIImage*)image mimeType:(NSString*)type {
dispatch_async(dispatch_get_main_queue(), ^{
[UIApplication sharedApplication].networkActivityIndicatorVisible++;
});
NSURL* channelURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discord.com/api/v9/channels/%@/messages", self.snowflake]];
NSURL* channelURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discordapp.com/api/v9/channels/%@/messages", self.snowflake]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30];
[urlRequest setValue:@"no-store" forHTTPHeaderField:@"Cache-Control"];
Expand Down Expand Up @@ -141,7 +141,7 @@ - (void)sendData:(NSData*)data mimeType:(NSString*)type {
dispatch_async(dispatch_get_main_queue(), ^{
[UIApplication sharedApplication].networkActivityIndicatorVisible++;
});
NSURL* channelURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discord.com/api/v9/channels/%@/messages", self.snowflake]];
NSURL* channelURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discordapp.com/api/v9/channels/%@/messages", self.snowflake]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30];
[urlRequest setValue:@"no-store" forHTTPHeaderField:@"Cache-Control"];
Expand Down Expand Up @@ -187,7 +187,7 @@ - (void)sendVideo:(NSURL*)videoURL mimeType:(NSString*)type {
dispatch_async(dispatch_get_main_queue(), ^{
[UIApplication sharedApplication].networkActivityIndicatorVisible++;
});
NSURL* channelURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discord.com/api/v9/channels/%@/messages", self.snowflake]];
NSURL* channelURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discordapp.com/api/v9/channels/%@/messages", self.snowflake]];

NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30];

Expand Down Expand Up @@ -239,7 +239,7 @@ - (void)sendVideo:(NSURL*)videoURL mimeType:(NSString*)type {

- (void)sendTypingIndicator{
dispatch_async([self get_channel_event_queue], ^{
NSURL* channelURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://discord.com/api/v9/channels/%@/typing", self.snowflake]];
NSURL* channelURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://discordapp.com/api/v9/channels/%@/typing", self.snowflake]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:5]; // low timeout to avoid API spam
[urlRequest setValue:@"no-store" forHTTPHeaderField:@"Cache-Control"];
Expand All @@ -264,7 +264,7 @@ - (void)sendTypingIndicator{
- (void)ackMessage:(NSString*)messageId{
self.lastReadMessageId = messageId;
dispatch_async([self get_channel_event_queue], ^{
NSURL* channelURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://discord.com/api/v9/channels/%@/messages/%@/ack", self.snowflake, messageId]];
NSURL* channelURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://discordapp.com/api/v9/channels/%@/messages/%@/ack", self.snowflake, messageId]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10];
[urlRequest setValue:@"no-store" forHTTPHeaderField:@"Cache-Control"];
Expand Down Expand Up @@ -298,7 +298,7 @@ - (NSArray*)getMessages:(int)numberOfMessages beforeMessage:(DCMessage*)message{

NSMutableArray* messages = NSMutableArray.new;
//Generate URL from args
NSMutableString* getChannelAddress = [[NSString stringWithFormat: @"https://discord.com/api/v9/channels/%@/messages?", self.snowflake] mutableCopy];
NSMutableString* getChannelAddress = [[NSString stringWithFormat: @"https://discordapp.com/api/v9/channels/%@/messages?", self.snowflake] mutableCopy];

if(numberOfMessages)
[getChannelAddress appendString:[NSString stringWithFormat:@"limit=%i", numberOfMessages]];
Expand Down
2 changes: 1 addition & 1 deletion Discord Classic/DCMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ - (dispatch_queue_t)get_messages_delete_queue {

- (void)deleteMessage{
dispatch_async([self get_messages_delete_queue], ^{
NSURL* messageURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discord.com/api/v9/channels/%@/messages/%@", DCServerCommunicator.sharedInstance.selectedChannel.snowflake, self.snowflake]];
NSURL* messageURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discordapp.com/api/v9/channels/%@/messages/%@", DCServerCommunicator.sharedInstance.selectedChannel.snowflake, self.snowflake]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:messageURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10];
[urlRequest setValue:@"no-store" forHTTPHeaderField:@"Cache-Control"];
Expand Down
2 changes: 1 addition & 1 deletion Discord Classic/DCTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ +(DCGuild *)convertJsonGuild:(NSDictionary*)jsonGuild{

+ (void)joinGuild:(NSString*)inviteCode {
//dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
NSURL* guildURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discord.com/api/v9/invite/%@", inviteCode]];
NSURL* guildURL = [NSURL URLWithString: [NSString stringWithFormat:@"https://discordapp.com/api/v9/invite/%@", inviteCode]];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:guildURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:15];
[urlRequest setValue:@"no-store" forHTTPHeaderField:@"Cache-Control"];
Expand Down

0 comments on commit 1303844

Please sign in to comment.