Visibility enum to string

FossilOrigin-Name: 78c011d7b0caba49e0e19b54c9113c2b650cd9048840abefd9e0e44ab90edd06
This commit is contained in:
nekobit 2022-06-14 16:05:26 +00:00
parent 4e2a9ae33b
commit 0cc4efb2a3
3 changed files with 30 additions and 1 deletions

View file

@ -100,6 +100,7 @@ enum l10n_string
L10N_VIS_PRIVATE,
L10N_VIS_DIRECT,
L10N_VIS_LOCAL,
L10N_VIS_LIST,
/* LOGIN */
L10N_LOGIN,
@ -200,6 +201,7 @@ static const char* const L10N[][_L10N_LEN] = {
"Private",
"Direct",
"Local",
"List",
/* LOGIN */
"Login",
@ -297,6 +299,7 @@ static const char* const L10N[][_L10N_LEN] = {
"Private",
"Direct",
"Local",
"List",
/* LOGIN */
"Login",
@ -394,6 +397,7 @@ static const char* const L10N[][_L10N_LEN] = {
"私密",
"私訊",
"本地",
"List",
/* LOGIN */
"登入",

View file

@ -134,6 +134,27 @@ void content_status_react(struct session* ssn, mastodont_t* api, char** data)
redirect(REDIRECT_303, referer);
}
const char* status_visibility_str(enum l10n_locale loc,
enum mstdnt_visibility_type vis)
{
switch (vis)
{
case MSTDNT_VISIBILITY_UNLISTED:
return L10N[loc][L10N_VIS_UNLISTED];
case MSTDNT_VISIBILITY_PRIVATE:
return L10N[loc][L10N_VIS_PRIVATE];
case MSTDNT_VISIBILITY_DIRECT:
return L10N[loc][L10N_VIS_DIRECT];
case MSTDNT_VISIBILITY_LOCAL:
return L10N[loc][L10N_VIS_LOCAL];
case MSTDNT_VISIBILITY_LIST:
return L10N[loc][L10N_VIS_LIST];
case MSTDNT_VISIBILITY_PUBLIC:
default:
return L10N[loc][L10N_VIS_PUBLIC];
}
}
int try_interact_status(struct session* ssn, mastodont_t* api, char* id)
{
int res = 0;
@ -570,6 +591,7 @@ char* construct_status(struct session* ssn,
char* delete_status = NULL;
char* pin_status = NULL;
char* interactions_html = NULL;
enum l10n_locale locale = l10n_normalize(ssn->config.lang);
struct mstdnt_status* status = local_status;
// Create a "fake" notification header which contains information for
// the reblogged status
@ -698,7 +720,7 @@ char* construct_status(struct session* ssn,
.username = formatted_display_name,
.prefix = config_url_prefix,
.acct = status->account.acct,
.visibility = status->visibility,
.visibility = status_visibility_str(locale, status->visibility),
.unmute = status->muted ? "un" : "",
.unmute_btn = status->muted ? "Unmute thread" : "Mute thread",
.unbookmark = status->bookmarked ? "un" : "",

View file

@ -20,6 +20,7 @@
#define STATUS_H
#include <stdint.h>
#include <mastodont.h>
#include "l10n.h"
#include "session.h"
// Flags
@ -102,6 +103,8 @@ char* make_mentions_local(char* content);
void status_view_reblogs(struct session* ssn, mastodont_t* api, char** data);
void status_view_favourites(struct session* ssn, mastodont_t* api, char** data);
const char* status_visibility_str(enum l10n_locale locale, enum mstdnt_visibility_type visibility);
void content_status_interactions(struct session* ssn,
mastodont_t* api,
char* label,