Merge remote-tracking branch 'upstream/develop' into masto-register-app-secret

* upstream/develop:
  Apply suggestion to src/services/entity_normalizer/entity_normalizer.service.js
  i18n/Update Japanese translation
  render modal at the root level using portal
  install portal vue
  Small improve of the who to follow panel layout
  Fix/Small fix in the who to follow page
  remove console spam
  i18n
  wire up user.description with masto api data
  i18n/Add Japanese with kanji (2)
  move drowdown menu to popper
  notification controls: redesign entirely
  entity normalizer: collapse data.pleroma if blocks
  wire up notification settings
  do not miss statusnet_profile_url of mentions
  Translation to Hebrew of everything other than theme_helpers and style.
  Translate up to settings.
  mastoapi login works
This commit is contained in:
Henry Jameson 2019-06-13 00:07:28 +03:00
commit 77511a5338
24 changed files with 1081 additions and 117 deletions

View file

@ -1,5 +1,4 @@
/* eslint-env browser */
const LOGIN_URL = '/api/account/verify_credentials.json'
const BG_UPDATE_URL = '/api/qvitter/update_background_image.json'
const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json'
const QVITTER_USER_NOTIFICATIONS_READ_URL = '/api/qvitter/statuses/notifications/read.json'
@ -15,7 +14,9 @@ const PERMISSION_GROUP_URL = (screenName, right) => `/api/pleroma/admin/users/${
const ACTIVATION_STATUS_URL = screenName => `/api/pleroma/admin/users/${screenName}/activation_status`
const ADMIN_USERS_URL = '/api/pleroma/admin/users'
const SUGGESTIONS_URL = '/api/v1/suggestions'
const NOTIFICATION_SETTINGS_URL = '/api/pleroma/notification_settings'
const MASTODON_LOGIN_URL = '/api/v1/accounts/verify_credentials'
const MASTODON_REGISTRATION_URL = '/api/v1/accounts'
const MASTODON_USER_FAVORITES_TIMELINE_URL = '/api/v1/favourites'
const MASTODON_USER_NOTIFICATIONS_URL = '/api/v1/notifications'
@ -97,6 +98,21 @@ const promisedRequest = ({ method, url, payload, credentials, headers = {} }) =>
})
}
const updateNotificationSettings = ({credentials, settings}) => {
const form = new FormData()
each(settings, (value, key) => {
form.append(key, value)
})
return fetch(NOTIFICATION_SETTINGS_URL, {
headers: authHeaders(credentials),
method: 'PUT',
body: form
})
.then((data) => data.json())
}
const updateAvatar = ({credentials, avatar}) => {
const form = new FormData()
form.append('avatar', avatar)
@ -507,8 +523,7 @@ const fetchPinnedStatuses = ({ id, credentials }) => {
}
const verifyCredentials = (user) => {
return fetch(LOGIN_URL, {
method: 'POST',
return fetch(MASTODON_LOGIN_URL, {
headers: authHeaders(user)
})
.then((response) => {
@ -520,6 +535,7 @@ const verifyCredentials = (user) => {
}
}
})
.then((data) => data.error ? data : parseUser(data))
}
@ -777,7 +793,8 @@ const apiService = {
markNotificationsAsSeen,
fetchFavoritedByUsers,
fetchRebloggedByUsers,
reportUser
reportUser,
updateNotificationSettings
}
export default apiService

View file

@ -87,6 +87,10 @@ const backendInteractorService = (credentials) => {
return apiService.deleteUser({screen_name, credentials})
}
const updateNotificationSettings = ({settings}) => {
return apiService.updateNotificationSettings({credentials, settings})
}
const fetchMutes = () => apiService.fetchMutes({credentials})
const muteUser = (id) => apiService.muteUser({credentials, id})
const unmuteUser = (id) => apiService.unmuteUser({credentials, id})
@ -171,7 +175,8 @@ const backendInteractorService = (credentials) => {
favorite,
unfavorite,
retweet,
unretweet
unretweet,
updateNotificationSettings
}
return backendInteractorServiceInstance

View file

@ -33,6 +33,7 @@ export const parseUser = (data) => {
if (masto) {
output.screen_name = data.acct
output.statusnet_profile_url = data.url
// There's nothing else to get
if (mastoShort) {
@ -42,7 +43,7 @@ export const parseUser = (data) => {
output.name = data.display_name
output.name_html = addEmojis(data.display_name, data.emojis)
// output.description = ??? missing
output.description = data.note
output.description_html = addEmojis(data.note, data.emojis)
// Utilize avatar_static for gif avatars?
@ -56,8 +57,6 @@ export const parseUser = (data) => {
output.bot = data.bot
output.statusnet_profile_url = data.url
if (data.pleroma) {
const relationship = data.pleroma.relationship
@ -72,6 +71,23 @@ export const parseUser = (data) => {
moderator: data.pleroma.is_moderator,
admin: data.pleroma.is_admin
}
// TODO: Clean up in UI? This is duplication from what BE does for qvitterapi
if (output.rights.admin) {
output.role = 'admin'
} else if (output.rights.moderator) {
output.role = 'moderator'
} else {
output.role = 'member'
}
}
if (data.source) {
output.description = data.source.note
output.default_scope = data.source.privacy
if (data.source.pleroma) {
output.no_rich_text = data.source.pleroma.no_rich_text
output.show_role = data.source.pleroma.show_role
}
}
// TODO: handle is_local
@ -106,8 +122,6 @@ export const parseUser = (data) => {
output.muted = data.muted
// QVITTER ONLY FOR NOW
// Really only applies to logged in user, really.. I THINK
if (data.rights) {
output.rights = {
moderator: data.rights.delete_others_notice,
@ -135,15 +149,16 @@ export const parseUser = (data) => {
if (data.pleroma) {
output.follow_request_count = data.pleroma.follow_request_count
}
if (data.pleroma) {
output.tags = data.pleroma.tags
output.deactivated = data.pleroma.deactivated
output.notification_settings = data.pleroma.notification_settings
}
output.tags = output.tags || []
output.rights = output.rights || {}
output.notification_settings = output.notification_settings || {}
return output
}