~tardypad/wee-most

b3c9943151c4af2e510369eaf98b507c5259eaa8 — Damien Tardy-Panis 11 days ago cad4d6a master
Use "me" instead of explicit user ID in URL

Decrease the number of arguments to pass around
3 files changed, 15 insertions(+), 15 deletions(-)

M wee_most/channel.py
M wee_most/http.py
M wee_most/server.py
M wee_most/channel.py => wee_most/channel.py +2 -2
@@ 48,7 48,7 @@ class ChannelBase:
        if last_post_id and last_post_id == last_read_post_id: # prevent spamming on buffer switch
            return

        wee_most.http.run_post_channel_view(self.server.me.id, self.id, self.server, "singularity_cb", "")
        wee_most.http.run_post_channel_view(self.id, self.server, "singularity_cb", "")

        weechat.buffer_set(self.buffer, "localvar_set_last_read_post_id", last_post_id)



@@ 281,7 281,7 @@ def create_channel_from_channel_data(channel_data, server):
    register_buffer_hydratating(server, channel_data["id"])
    wee_most.http.enqueue_request(
        "run_get_read_channel_posts",
        server.me.id, channel_data["id"], server, "hydrate_channel_read_posts_cb", channel.buffer
        channel_data["id"], server, "hydrate_channel_read_posts_cb", channel.buffer
    )
    wee_most.http.enqueue_request(
        "run_get_channel_members",

M wee_most/http.py => wee_most/http.py +10 -10
@@ 67,8 67,8 @@ def handle_queued_request_cb(data, remaining_calls):
    eval(request[0])(*request[1])
    return weechat.WEECHAT_RC_OK

def run_get_user_teams(user_id, server, cb, cb_data):
    url = server.url + "/api/v4/users/" + user_id + "/teams"
def run_get_user_teams(server, cb, cb_data):
    url = server.url + "/api/v4/users/me/teams"
    weechat.hook_process_hashtable(
        "url:" + url,
        {


@@ 166,8 166,8 @@ def run_get_channel(channel_id, server, cb, cb_data):
        build_buffer_cb_data(url, cb, cb_data)
    )

def run_get_user_team_channels(user_id, team_id, server, cb, cb_data):
    url = server.url + "/api/v4/users/" + user_id + "/teams/" + team_id + "/channels"
def run_get_user_team_channels(team_id, server, cb, cb_data):
    url = server.url + "/api/v4/users/me/teams/" + team_id + "/channels"
    weechat.hook_process_hashtable(
        "url:" + url,
        {


@@ 220,8 220,8 @@ def run_post_command(channel_id, command, server, cb, cb_data):
        build_buffer_cb_data(url, cb, cb_data)
    )

def run_get_read_channel_posts(user_id, channel_id, server, cb, cb_data):
    url = server.url + "/api/v4/users/" + user_id + "/channels/" + channel_id + "/posts/unread?limit_after=1"
def run_get_read_channel_posts(channel_id, server, cb, cb_data):
    url = server.url + "/api/v4/users/me/channels/" + channel_id + "/posts/unread?limit_after=1"
    weechat.hook_process_hashtable(
        "url:" + url,
        {


@@ 259,8 259,8 @@ def run_get_channel_members(channel_id, server, page, cb, cb_data):
        build_buffer_cb_data(url, cb, cb_data)
    )

def run_post_channel_view(user_id, channel_id, server, cb, cb_data):
    url = server.url + "/api/v4/channels/members/" + user_id + "/view"
def run_post_channel_view(channel_id, server, cb, cb_data):
    url = server.url + "/api/v4/channels/members/me/view"
    params = {
        "channel_id": channel_id,
    }


@@ 299,7 299,7 @@ def run_post_reaction(emoji_name, post_id, server, cb, cb_data):
    )

def run_delete_reaction(emoji_name, post_id, server, cb, cb_data):
    url = server.url + "/api/v4/users/" + server.me.id + "/posts/" + post_id + "/reactions/" + emoji_name
    url = server.url + "/api/v4/users/me/posts/" + post_id + "/reactions/" + emoji_name

    weechat.hook_process_hashtable(
        "url:" + url,


@@ 344,7 344,7 @@ def run_get_file(file_id, file_out_path, server, cb, cb_data):
    )

def run_get_preferences(server, cb, cb_data):
    url = server.url + "/api/v4/users/" + server.me.id + "/preferences"
    url = server.url + "/api/v4/users/me/preferences"

    weechat.hook_process_hashtable(
        "url:" + url,

M wee_most/server.py => wee_most/server.py +3 -3
@@ 231,7 231,7 @@ def connect_server_users_cb(data, command, rc, out, err):
    else:
        wee_most.http.enqueue_request(
            "run_get_user_teams",
            server.me.id, server, "connect_server_teams_cb", server.id
            server, "connect_server_teams_cb", server.id
        )

    return weechat.WEECHAT_RC_OK


@@ 265,7 265,7 @@ def connect_server_teams_cb(server_id, command, rc, out, err):

        wee_most.http.enqueue_request(
            "run_get_user_team_channels",
            server.me.id, team_data["id"], server, "connect_server_team_channels_cb", server.id
            team_data["id"], server, "connect_server_team_channels_cb", server.id
        )

    return weechat.WEECHAT_RC_OK


@@ 283,7 283,7 @@ def connect_server_team_cb(server_id, command, rc, out, err):

    wee_most.http.enqueue_request(
        "run_get_user_team_channels",
        server.me.id, team_data["id"], server, "connect_server_team_channels_cb", server.id
        team_data["id"], server, "connect_server_team_channels_cb", server.id
    )

    return weechat.WEECHAT_RC_OK