Coder Social home page Coder Social logo

Posting Slack Messages about channelsurf HOT 6 OPEN

tamhinsf avatar tamhinsf commented on May 26, 2024 1
Posting Slack Messages

from channelsurf.

Comments (6)

tamhinsf avatar tamhinsf commented on May 26, 2024

Some endpoints in the MS Graph API will insert a retry-after value in the response header when returning a 429 code. Teams isn't indicated as being one of them, but docs have been known to be wrong.

https://developer.microsoft.com/en-us/graph/docs/concepts/throttling

Batching may not necessarily make things better: it depends how the Teams API that sits underneath the Graph is counting API calls.

from channelsurf.

argvMatey avatar argvMatey commented on May 26, 2024

Yeah, I saw that page as well, and I can confirm that there's no retry-after value in the response header. Since batching the requests doesn't result in more messages being posted, I'm assuming there's a hard limit in the Teams API on the number of posts per hour. Throttling seems to reset after an hour.

Also, this bit of code will return a new token after the original expires. Right now i am just returning the new token from postMessage, so it will only allow you to upload a single channel because the new token never makes it back to the GetAndUploadMessages loop at the top of Messages.cs, but because we are making a new team for each channel, it works well enough for our purposes. Sorry for linearizing your beautifully object oriented program!

if (j["error"]["code"].ToString() == "InvalidAuthenticationToken")
{
// need to re-authenticate when token expires - made authenticationcontext public static
//this piece is successfully re-authenticating
//new access token is returned from method
string newToken = Program.authenticationContext.AcquireTokenSilentAsync(Program.aadResourceAppId, Program.Configuration["AzureAd:ClientId"]).Result.AccessToken;

                Helpers.httpClient.DefaultRequestHeaders.Clear();
                Helpers.httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", newToken);
                Helpers.httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

from channelsurf.

haraldreingruber avatar haraldreingruber commented on May 26, 2024

@argvMatey Thanks for sharing your improvements. Do you still have the code? Could you share it as a Pull-Request? I guess it would increase the chance somebody building on the progress you have made.

from channelsurf.

iradzik avatar iradzik commented on May 26, 2024

is that code posted anywhere i am running into issues when i try and run it

from channelsurf.

dschief001 avatar dschief001 commented on May 26, 2024

@tamhinsf is there any new development into this direction going on, would be great, to fix this issue?
and make the result... way more "pretty"

from channelsurf.

JustinWalker72 avatar JustinWalker72 commented on May 26, 2024

We can import chats from slack to teams for more information you may want to take a look at this Slack to Teams migration guide.
https://www.cloudfuze.com/slack-to-teams-migration-guide-for-it-admins/

from channelsurf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.